I'm using the elasticsearch module in a nodejs app in order to find document by geo_points.
according to http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search , i'm trying to do this :
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 I always got a search parsing error.
Does someone got an idea?
Thx
Finaly, I found the 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 for your help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.