gpt4 book ai didi

node.js - Elasticsearch搜索解析异常,但返回结果

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

我将ELasticsearch和Meteor.js与npm / elasticsearch插件一起使用,将ES与Meteor一起使用。
这是我的查询:

search = {
"body": {
"aggs": {
"traces": {
"filter": {
"and": [
{
"range": {
"date": {
"gte": "2015-01-31T23:00:00.000Z",
"lte": "2015-10-02T21:59:59.000Z"
}
}
},
{
"geo_bounding_box": {
"loc.coordinates": {
"top_left": {
"lat": 51.767839887322154,
"lon": -9.404296875
},
"bottom_right": {
"lat": 40.96330795307353,
"lon": 14.326171874999998
}
}
}
},
{
"or": [
{
"and": [
{
"term": {
"geoip": false
}
},
{
"term": {
"trackerId": "RG-000000010-1"
}
}
]
}
]
}
]
},
"aggs": {
"trackerId": {
"terms": {
"field": "trackerId",
"size": 0
},
"aggs": {
"heatmap": {
"geohash_grid": {
"field": "loc.coordinates",
"precision": 6
}
}
}
}
}
}
}
}
}

我用 esClient.search(search)发送它并收到异常(exception)的答案,但是ES抛出此错误:
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:735)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:560)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:532)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:294)
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: [.marvel-2015.10.02]
**failed to find geo_point field [loc.coordinates]**
at org.elasticsearch.index.query.GeoBoundingBoxFilterParser.parse(GeoBoundingBoxFilterParser.java:173)
at org.elasticsearch.index.query.QueryParseContext.executeFilterParser(QueryParseContext.java:368)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:349)
at org.elasticsearch.index.query.AndFilterParser.parse(AndFilterParser.java:65)
at org.elasticsearch.index.query.QueryParseContext.executeFilterParser(QueryParseContext.java:368)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:349)
at org.elasticsearch.index.query.IndexQueryParserService.parseInnerFilter(IndexQueryParserService.java:295)
at org.elasticsearch.search.aggregations.bucket.filter.FilterParser.parse(FilterParser.java:42)
at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:148)
at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:78)
at org.elasticsearch.search.aggregations.AggregationParseElement.parse(AggregationParseElement.java:60)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:719)

显然,它找不到geo_point字段类型。

这是我映射的启示部分:
{
'trace': {
'properties': {
'loc': {
'type': 'object',
'properties': {
'type': {
'type': 'string'
},
'coordinates':{
'type': 'geo_point',
'geohash':true,
'geohash_prefix':true,
'lat_lon':true,
'fielddata' : {
'format' : 'compressed',
'precision' : '1cm'
}
}
}
}
...

那么为什么找不到geo_point类型呢?

最佳答案

您需要将查询发送到包含trace类型文档的索引。如果将查询发送到根端点/(如果未指定,则为默认值),则将查询所有索引。在您的情况下,此操作失败,因为.marvel-2015.10.02索引没有名为geo_pointloc.coordinates字段。

因此,您的通话应如下所示:

var search = {
index: "your_index", <--- add this
body: {...}
};
esClient.search(search);

关于node.js - Elasticsearch搜索解析异常,但返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32904556/

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