Простой пример поиска по нескольким местоположениям. Сопоставление:
PUT location
{
"mappings": {
"properties" : {
"pin" : {
"type" : "geo_point"
}
}
}
}
Данные:
[
{
"_index" : "location",
"_type" : "_doc",
"_id" : "rhn8f20BIb7c4jbYhr3Z",
"_score" : 1.0,
"_source" : {
"pin" : {
"lat" : 40.73,
"lon" : -74.1
}
}
},
{
"_index" : "location",
"_type" : "_doc",
"_id" : "rxn8f20BIb7c4jbYz709",
"_score" : 1.0,
"_source" : {
"pin" : {
"lat" : 40.717,
"lon" : -73.99
}
}
}
]
Запрос:
GET location/_search
{
"query": {
"bool": {
"should": [ ---> multiple filters in should clause , either one of these has to be true
{
"geo_distance" : {
"distance" : "1km",
"pin" : {
"lat" : 40.73,
"lon" : -74.1
}
}
},
{
"geo_distance" : {
"distance" : "1km",
"pin" : {
"lat" : 40.717,
"lon" : -73.99
}
}
}
]
}
}
}