Elasticsearch node.js geo_distance filter -
i'm using elasticsearch module in nodejs app in order find document geo_points.
according http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search, i'm trying :
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"); });
but got search parsing error.
does got idea?
thx
finaly, found correct syntax / parameters :
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 help.
Comments
Post a Comment