Home > Blockchain >  Elastich search sorting by location distance, "Sort direction ' is not 'asc' or
Elastich search sorting by location distance, "Sort direction ' is not 'asc' or

Time:01-10

{ "query": "", "page": { "size": 18 }, "filters": { "all": [ { "published": "1" }, { "psid": "58" } ] }, "sort": [ { "geopoint": { "pin.location": [ 4.342083917809, -2.9475302108444 ], "order": "asc", "unit": "km", "mode": "min", "distance_type": "arc", "ignore_unmapped": true } } ] }

i'm receiving error like this :

{
"errors": [
    "Sort direction '{\"pin.location\"=>[4.342083917809, -2.9475302108444], \"order\"=>\"asc\", \"unit\"=>\"km\", \"mode\"=>\"min\", \"distance_type\"=>\"arc\", \"ignore_unmapped\"=>true}' is not 'asc' or 'desc'"
]

}

I do not understand. Please need help.

CodePudding user response:

It should be called _geo_distance not geopoint, see example in the docs

CodePudding user response:

you should be using _geo_distance instead of geopoint, this is how it should be according to the official docs:

"sort" : [
    {
        "_geo_distance" : {
            "pin.location" : [-70, 40],
            "order" : "asc",
            "unit" : "km",
            "mode" : "min",
            "distance_type" : "arc",
            "ignore_unmapped": true
        }
    }
],
  •  Tags:  
  • Related