【发布时间】:2015-01-24 01:07:54
【问题描述】:
我正在使用 ElasticSearch (1.4.0) 执行搜索。
我已经成功设置了 ElasticSearch,除了 geo_location 过滤器之外,一切都很好。
每当我使用 geo_location 过滤器时,都不会返回任何结果。 请注意,ElasticSearch 不会返回任何错误。即使我确保在我的搜索点附近有实体,也没有返回任何命中。
这是我用来测试 geo_distance 过滤器的 PHP 参数数组的简化版本:
$searchParams['index'] = 'myname';
$searchParams['type'] = 'myentity';
$searchParams['body']['query']['filtered']['filter']['geo_distance'] =
[
'distance' => '50km',
'address.geopoint' => $lat . "," $lng
];
这是 curl 请求正文,它也不返回任何命中:
{
"query" : {
"filtered" : {
"filter" : {
"geo_distance" : {
"distance" : "50km",
"address.geopoint" : "51.43,-2.54"
}
}
}
}
}
这是我的映射:
{
"myname":{
"mappings":{
"myentity":{
"properties":{
"address":{
"type":"nested",
"properties":{
"country":{
"type":"string"
},
"geopoint":{
"type":"geo_point",
"lat_lon":true
},
"house":{
"type":"string"
},
"postcode":{
"type":"string"
},
"street":{
"type":"string"
},
"town":{
"type":"string"
}
}
},
"categories":{
"type":"string"
},
"tags":{
"type":"string"
}
}
}
}
}
}
这是我希望得到的文件:
[_source] => Array (
[categories] => Array (
)
[tags] => Array (
)
[address] => Array (
[street] => Bristol Road
[geopoint] => 51.4307381,-2.5417914
[town] => Bristol
[house] => 1
[postcode] => BS4 5NL
[country] => UK
)
)
任何帮助将不胜感激。
【问题讨论】:
-
我建议在你的 php 客户端中尝试一下。只需使用
curl或marvel。如果问题仍然存在,请使用您的查询、您认为应该返回的数据、映射和 ES 版本更新帖子。 -
我尝试过使用 curl,但还是一样。 PHP 客户端和 curl 都给出相同的结果。我用更多数据更新了我的问题。任何帮助将不胜感激。
标签: php elasticsearch