我使用ELpm和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)
并收到例外回答,但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类型?
答案 0 :(得分:1)
您需要将查询发送到包含trace
类型文档的索引。如果将查询发送到根端点/
(如果未指定,则为默认值),则将查询所有索引。在您的情况下,它会失败,因为.marvel-2015.10.02
索引没有任何名为geo_point
的{{1}}字段。
所以你的电话需要看起来像这样:
loc.coordinates