gpt4 book ai didi

elasticsearch - ElasticSearch SearchParseException:使用geo_distance过滤器时,解析失败[解析源失败]

转载 作者:行者123 更新时间:2023-12-03 00:09:00 24 4
gpt4 key购买 nike

我是ElasticSeach的新手,已经为elasticseach集群中的城市列表编制了索引。每个城市包含的详细信息,例如城市,州,位置(经纬度)等。

现在,我的要求是搜索特定位置20公里范围内的城市,对于这些城市,我要经过纬度,而对于已经索引到群集中的特定城市,则要经过很长时间。

这是我在elasticsearch头插件的UI中显示的索引数据:

{
"_index": "us_large_cities",
"_type": "city",
"_id": "AVqDpwkjfjWoT7yVe_qt",
"_version": 1,
"_score": 1,
"_source": {
"city": "Lincoln",
"state": "NE",
"location": {
"lat": "40.8000011",
"lon": "-96.6669599"
}
}
}

这是我的curl命令,用于搜索数据:
curl -XGET 'http://localhost:9200/us_large_cities/city/_search?pretty=true' -d '
{
"query": {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "20km",
"location" : {
"lat" : 40.8000011,
"lon" : -96.6669599
}
}
}
}
}
}'

我得到了SearchParseException,这是完整的堆栈跟踪:
org.elasticsearch.search.SearchParseException: [us_large_cities][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [
{
"query": {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "20km",
"location" : {
"lat" : 40.8000011,
"lon" : -96.6669599
}
}
}
}
}
}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:687)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:543)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:515)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:277)
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:231)
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:228)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.index.query.QueryParsingException: [us_large_cities] failed to find geo_point field [location]
at org.elasticsearch.index.query.GeoDistanceFilterParser.parse(GeoDistanceFilterParser.java:159)
at org.elasticsearch.index.query.QueryParseContext.executeFilterParser(QueryParseContext.java:347)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:328)
at org.elasticsearch.index.query.FilteredQueryParser.parse(FilteredQueryParser.java:74)
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:281)
at org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:382)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:281)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:276)
at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:671)
... 9 more

我已经搜索了SO中的各种帖子,但没有一个对我有用。
有什么建议,我在哪里犯错?

最佳答案

[us_large_cities] failed to find geo_point field [location]

这是您的错误,因为如果您想使用 geo_distance过滤器,则必须将位置字段索引为 geo_point字段。更多信息 here

编辑:所以
"location": {
"lat": "40.8000011",
"lon": "-96.6669599"
}

需要定义为:
{
"city_location" : {
"location" : {
"lat" : 41.12,
"lon" : -71.34
}
}
}

关于elasticsearch - ElasticSearch SearchParseException:使用geo_distance过滤器时,解析失败[解析源失败],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42503595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com