Express-cassandra elassandra sorting by geo_point

114 views Asked by At

I have the following UDT:

udts: {
  geo_point: {
    lat: 'double',
    lon: 'double'
  }
}

The following geoloc defined in cassandra model:

geoloc: {
  type: 'frozen',
  typeDef: '<geo_point>'
}

And elasticsearch mapping:

    "geoloc": {
        "type": "geo_point",
        cql_collection: 'singleton',
        "index" : true
    },

I can insert objects with geo_point location and query for them in elasticsearch (they appear normally as "geoloc":{"lon":34.855744,"lat":31.913353}), I can confirm the structure is correct in elasticsearch but every time I try to sort by distance using:

sort: [{
    "_geo_distance": {
        "geoloc": {
            "lat" : -2.172273,
            "lon" : 43.284734
        },
        "order": "asc",
        // "unit": "km",
        // "distance_type": "plane"
    }
}]

I get the following exception:

 No mapping found for [[object Object]] in order to sort on
1

There are 1 answers

0
Max0999 On BEST ANSWER

Sort should be defined inside body, that was the problem.