Sử dụng library ClientBuilder (ok)
<?php
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->build();
$query = '
{
"query": {
"bool": {
"must":
[
{
"bool": {
"must": [
{
"multi_match": {
"query": "809 giải phóng",
"type": "phrase",
"fields": [
"meta.webbupointfinder_items_address.value^1"
]
}
}
]
}
}
],
"filter":
[
{
"term" : { "terms.pointfinderltypes.term_id" : 107}
}
]
}
},
"sort": [
{
"_geo_distance" : {
"geo_point.location" : "20.983368995878337,105.84153423865689",
"order" : "asc",
"unit" : "km"
}
},
"_score"
]
}';
$params = [
"index" => "ypvn-post-1",
"body" => $query
];
$response = $client->search($params);
print_r($response); ?>
curl -X GET "localhost:9200/ypvn-post-1/_search?pretty" -H 'Content-Type: application/json' -d '
{
"query": {
"bool": {
"must":
[
{
"bool": {
"must": [
{
"multi_match": {
"query": "cà phê",
"type": "phrase",
"fields": [
"post_title^1",
"post_content^2",
"terms.pointfinderltypes.name^1",
"terms.ep_custom_result.name^9999"
]
}
}
]
}
}
],
"filter":
[
{
"term" : { "terms.pointfinderltypes.term_id" : 107}
}
]
}
},
"sort": [
{
"_geo_distance" : {
"geo_point.location" : "20.983368995878337,105.84153423865689",
"order" : "asc",
"unit" : "km"
}
},
"_score"
]
}'
curl -X GET "localhost:9200/ypvn-post-1/_search?pretty" -H 'Content-Type: application/json' -d '
{
"query": {
"bool": {
"must":
[
{
"bool": {
"must": [
{
"multi_match": {
"query": "cà phê",
"type": "phrase",
"fields": [
"post_title^1",
"post_content^2",
"terms.pointfinderltypes.name^1",
"terms.ep_custom_result.name^9999"
]
}
}
]
}
}
],
"filter":
[
{
"term" : { "terms.pointfinderltypes.term_id" : 107}
}
]
}
},
"sort": [
{
"_geo_distance" : {
"geo_point.location" : "20.983368995878337,105.84153423865689",
"order" : "asc",
"unit" : "km"
}
},
"_score"
]
}'
curl -X GET "localhost:9200/ypvn-post-1/_search?pretty" -H 'Content-Type: application/json' -d '
{
"query": {
"bool": {
"must":
[
{
"bool": {
"must": [
{
"multi_match": {
"query": "cà phê",
"type": "phrase",
"fields": [
"post_title^1",
"post_content^2",
"terms.pointfinderltypes.name^1",
"terms.ep_custom_result.name^9999"
]
}
}
]
}
}
],
"filter":
[
{
"term" : { "terms.pointfinderltypes.term_id" : 107}
}
]
}
},
"sort": [
{
"_geo_distance" : {
"geo_point.location" : "20.983368995878337,105.84153423865689",
"order" : "asc",
"unit" : "km"
}
},
"_score"
]
}'
curl -X GET "localhost:9200/ypvn-term-1/_search?pretty"
Last updated