如何在elasticsearch中对地理坐标应用filter?

我正在使用elasticsearch和mongoosastic npm模块。 我正在尝试在具有以下模型结构的地理坐标上应用滤镜

geoLocation: { type: { type: String, default: 'Point' }, coordinates: [Number] //orders should be lat,lng } 

与映射如下

 { "events": { "settings": { "analysis": { "filter": { "edgeNGram_filter": { "type": "edgeNGram", "min_gram": 1, "max_gram": 50, "side": "front" } }, "analyzer": { "edge_nGram_analyzer": { "type": "custom", "tokenizer": "edge_ngram_tokenizer", "filter": [ "lowercase", "asciifolding", "edgeNGram_filter" ] }, "whitespace_analyzer": { "type": "custom", "tokenizer": "whitespace", "filter": [ "lowercase", "asciifolding" ] } }, "tokenizer": { "edge_ngram_tokenizer": { "type": "edgeNGram", "min_gram": "1", "max_gram": "50", "token_chars": [ "letter", "digit" ] } } } }, "mappings": { "event": { "_all": { "index_analyzer": "nGram_analyzer", "search_analyzer": "whitespace_analyzer" }, "properties": { "title": { "type": "string", "index": "not_analyzed" }, "geoLocation": { "index": "not_analyzed", "type": "geo_point" } } } } } } 

询问

 { "query": { "multi_match": { "query": "the", "fields": ["title", ] } }, "filter" : { "geo_distance" : { "distance" : "200km", "geoLocation.coordinates" : { "lat" : 19.007452, "lon" : 72.831556 } } } } 

我无法使用以下模型结构在地理坐标上创build索引,我不明白是否不可能使用上面的模型结构来索引地理坐标,因为在我的情况下,坐标的顺序是lat,long,而且我find了某处elasticsearch预计坐标顺序为long,lat。

错误

错误:SearchPhaseExecutionException [无法执行阶段[查询],所有碎片失败; shardFailures {[CDHdgtJnTbeu8tl2mDfllg] [events] [0]:SearchParseException [[events] [0]:from [-1],size [-1]:parsing失败[Failed to parse source

curl -XGET localhost:9200 / events

 { "events": { "aliases": {}, "mappings": { "1": { "properties": { "location": { "type": "double" }, "text": { "type": "string" } } }, "event": { "properties": { "city": { "type": "string" }, "endTime": { "type": "date", "format": "dateOptionalTime" }, "geo_with_lat_lon": { "type": "geo_point", "lat_lon": true }, "isActive": { "type": "boolean" }, "isRecommended": { "type": "boolean" }, "location": { "type": "string" }, "title": { "type": "string" } } } }, "settings": { "index": { "creation_date": "1461675012489", "uuid": "FT-xVUdPQtyuKFm4J4Rd7g", "number_of_replicas": "1", "number_of_shards": "5", "events": { "mappings": { "event": { "_all": { "enabled": "false", "search_analyzer": "whitespace_analyzer", "index_analyzer": "nGram_analyzer" }, "properties": { "geoLocation": { "coordinates": { "type": "geo_shape", "index": "not_analyzed" } }, "location": { "type": "string", "index": "not_analyzed" }, "title": { "type": "string", "index": "not_analyzed" }, "geo_with_lat_lon": { "type": "geo_point", "lat_lon": "true", "index": "not_analyzed" } } } }, "settings": { "analysis": { "analyzer": { "edge_nGram_analyzer": { "type": "custom", "filter": [ "lowercase", "asciifolding", "edgeNGram_filter" ], "tokenizer": "edge_ngram_tokenizer" }, "whitespace_analyzer": { "type": "custom", "filter": [ "lowercase", "asciifolding" ], "tokenizer": "whitespace" } }, "filter": { "edgeNGram_filter": { "max_gram": "50", "type": "edgeNGram", "min_gram": "1", "side": "front" } }, "tokenizer": { "edge_ngram_tokenizer": { "max_gram": "50", "type": "edgeNGram", "min_gram": "1", "token_chars": [ "letter", "digit" ] } } } } }, "version": { "created": "1070099" } } }, "warmers": {} } } 

我得到了一个解决我的问题

制图

PUT / geo_test

 { "mappings": { "type_test": { "properties": { "name": { "type": "string" }, "geoLocation": { "type": "nested", "properties": { "coordinates": { "type": "geo_point", "lat_lon": true } } } } } } } 

询问

POST / geo_test / type_test / _search

 { "query": { "filtered": { "filter": { "nested": { "path": "geoLocation", "query": { "filtered": { "filter": { "geo_distance": { "distance": 5, "distance_unit": "km", "geoLocation.coordinates": { "lat": 41.12, "lon": -71.34 } } } } } } } } } }