2
作ることができます
私のスキーマはマングースのために次のようになります。Mongoosastic、どのように私はジオの距離クエリ
var articleSchema = new Schema({
Name: {type: String, es_indexed: true},
geo_with_lat_lon: {
geo_point: {
type: String,
es_type: 'geo_point',
es_lat_lon: true
},
lat: {type: Number},
lon: {type: Number}
},
...
});
私は新しいドキュメントを追加:
var artikel = new global.DBModel.article({
Name:"Test",
geo_with_lat_lon:{lon:-70,lat:40}
});
artikel.save(...);
今私がでフィルタリングしたいと思いますが距離。私のクエリは次のようになります。
global.DBModel.article.search({
"bool": {
"must": {
"match_all": {}
},
"filter" :{
"geo_distance": {
"distance": "200km",
"geo_with_lat_lon": {
"lat": 40,
"lon": -70
}
}
}
}
}, {...}
しかし、私は常にエラーに
{
"error": {
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "failed to find geo_point field [geo_with_lat_lon]",
"index": "articles",
"line": 1,
"col": 127
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "articles",
"node": "YdQHw7nSRc-T0LwItupmmw",
"reason": {
"type": "query_parsing_exception",
"reason": "failed to find geo_point field [geo_with_lat_lon]",
"index": "articles",
"line": 1,
"col": 127
}
}
]
},
"status": 400 }
を取得する私の質問は:どのように私は距離によって正しくフィルタリングすることができますか?
は問題があなたのフィルタについてのが、あなたのマッピングに関するものではありません。あなたのelasticsearchデータベースで 'geo_with_lat_lon'のタイプを確認できますか? – Paradise228
回答には[SOスレッド](http://stackoverflow.com/questions/30500454/geocode-filter-in-mongoose-elasticsearch)をフォローすることができます – Paradise228