Elasticsearch node.js geo_distancefilter
我正在使用nodejs应用程序中的elasticsearch模块来按照geo_points查找文档。
根据http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search ,我试图做到这一点:
client.search({ index: 'myindex', type: 'mytype', body: { filtered : { query : { match_all : {} }, filter : { geo_distance : { distance : "200km", coordiates : { lat : 40, lon : -70 } } } } } }).then(function (resp) { var hits = resp.hits.hits; console.log(hits, "items"); }).catch(function (error) { console.log("Error on geo_distance"); });
但我总是得到一个searchparsing错误。
有人有想法吗?
谢谢
最后,我find了正确的语法/参数:
client.search({ index: 'myindex', type: 'mytype', body: { from: from, size: size, query: { filtered: { filter: { geo_distance: { distance: '100000km', coordiates: { lat: 0.0, lon: 0.0 } } } } } } }).then(function (resp) { var hits = resp.hits.hits; console.log(hits.length, "items around"); }).catch(function (error) { console.log("Error on geo_distance (coordiates)"); });
Thx Jhilden为您提供帮助。