elasticsearchcassandraexpress-cassandra

Express-cassandra elassandra sorting by geo_point


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

Solution

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