Error- Geo Distance Sorting

Hello ,
let body = {
"query": {
"bool": {
"should": [
{
"match": {
}
},
{
"geo_distance": {
"distance": targetDistance+"km",
"location": {
"lat": location.lat,
"lon": location.lon
}
}
}
]
}
},
"sort": [
{
"_geo_distance": {
"location":[location.lat,location.lon],
"order": "asc",
"unit": "km",
"mode": "min",
"distance_type": "arc",
"ignore_unmapped": true
}
}
]
};
Error {
error: {
root_cause: [ [Object] ],
type: 'parsing_exception',
reason: 'No text specified for text query',
line: 1,
col: 39
},
status: 400
}
Any Help ? @elastic/elasticsearch : "version": "7.5.0",
Note : I try to use performatted text but it doesn't work

Hello,
the problem solved using

let body = {
       "query": {
         "bool": {
           "must": [
             {
               "exists": {
                 "field": "location"
             }
             },
             {
               "geo_distance": {
                 "distance": targetDistance+"km",
                 "location": {
                   "lat": location.lat,
                   "lon": location.lon
                 }
               }
             }
           ]
         }
       },
       "sort": [
         {
           "_geo_distance": {
             "location": {
               "lat": location.lat,
               "lon": location.lon
             },
             "order": "asc"
           }
         }
       ]
 };

with client.search({index: index, body: body})

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.