Php 弹性搜索地理点查询过滤器
我尝试使用地理点表示距离,但它始终显示位置类型double not geo_point如何设置映射到地理点的位置 实际上,我必须找到5公里内的所有记录Php 弹性搜索地理点查询过滤器,php,codeigniter,elasticsearch,Php,Codeigniter,elasticsearch,我尝试使用地理点表示距离,但它始终显示位置类型double not geo_point如何设置映射到地理点的位置 实际上,我必须找到5公里内的所有记录 "pin" : { "properties" : { "location" : { "properties" : { "lat" : { "type" : "double" },
"pin" : {
"properties" : {
"location" : {
"properties" : {
"lat" : {
"type" : "double"
},
"lon" : {
"type" : "double"
}
}
},
"type" : {
"type" : "string"
}
}
},
当我尝试使用下面的查询进行搜索以查找距离德里拉特5公里以内的结果时:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"pin": {
"distance": "5",
"distance_unit": "km",
"coordinate": {
"lat": 28.5402707,
"lon": 77.2289643
}
}
}
}
}
}
它向我显示错误查询\解析\异常,并且没有为[pin]注册查询。我想不出这个问题。它总是抛出这个异常
{
"error": {
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "No query registered for [pin]",
"index": "find_index",
"line": 1,
"col": 58
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "find_index",
"node": "DtpkEdLCSZCr8r2bTd8p5w",
"reason": {
"type": "query_parsing_exception",
"reason": "No query registered for [pin]",
"index": "find_index",
"line": 1,
"col": 58
}
}
]
},
"status": 400
}
请帮我解决这个问题。如何设置geo_point并解决此异常错误和状态400以及所有_shards_failed错误您只需像这样映射您的
pin
类型,即使用:
然后可以像这样为文档编制索引
PUT shouut_find_index/search_shouut/1
{
"location": {
"lat": 28.5402707,
"lon": 77.2289643
},
"type": "dummy"
}
POST shouut_find_index/search_shouut/_search
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 28.5402707,
"lon": 77.2289643
}
}
}
}
}
}
最后,您的查询可以如下所示
PUT shouut_find_index/search_shouut/1
{
"location": {
"lat": 28.5402707,
"lon": 77.2289643
},
"type": "dummy"
}
POST shouut_find_index/search_shouut/_search
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 28.5402707,
"lon": 77.2289643
}
}
}
}
}
}
嗨,瓦尔。。。。你能帮我设置类型geo_点吗?因为它总是显示类型double not geo_点。你需要先删除你的索引并重新创建它。查看我的更新答案在创建索引之前或之后,我需要插入相关数据库数据的内容??1)删除索引,2)使用正确的映射再次创建它3)使用数据库数据填充它4)查询它如果有人像我一样笨,想节省15分钟的时间,请注意该字段称为“lon”而不是“long”。