masumsoft/express-cassandra

geo_point mapping fails

Closed this issue · 2 comments

The mapping to an elastic search geo_point doesn't seem to work.

geopoint UDT:

      manageESIndex: true,
      udts: {
        geopoint: {
          latitude: 'double',
          longitude: 'double'
        }
      }

cassandra table elastic mapping:

    location: {
      type: 'frozen',
      typeDef: '<geopoint>'
    }
  ...
  es_index_mapping: {
    discover: '.*',
    properties: {
      "location": {
        "type": "geo_point"
      }
    }
  }

The resulting elastic mapping is:

                    "location": {
                        "type": "nested",
                        "cql_collection": "singleton",
                        "cql_udt_name": "geopoint",
                        "properties": {
                            "latitude": {
                                "type": "double",
                                "cql_collection": "singleton"
                            },
                            "longitude": {
                                "type": "double",
                                "cql_collection": "singleton"
                            }
                        }
                    }

As can be seen, the mapping results in a latitude / longitude mapping, but I think this should be 'geo_point' instead.

Could you try to create a geo_point mapping directly using elassandra and see if the behaviour there is the same? My gut feeling is the issue might be related to elassandra as express-cassandra passes the index mapping as is to elassandra and depends on the discover feature of elassandra to sync the model to elasticsearch.

Please let me know if you find it to be an express-cassandra related issue. If so I'll try to dig into it.

Dear Masum,

I solved it by:

  1. defining UDT called geo_point ( and not geopoint ).
  2. making sure the collumn location is excluded from the auto discover mapping:
    discover: "^((?!location).*)"
  3. adding singleton collection setting to the location property:
      "location": {
        "type": "geo_point",
        "cql_collection": "singleton"
      }

Points 2 and 3 are also important when we want to set an analyzer on full text field.
I believe each field for which we want to override the mapping must be excluded from the auto discovery function and set to correct mapping type (singleton). I think this should be mentioned in the documentation for elassandra-express.

After the above changes, the mapping to elastic geo_point works :)
I still need to test how the source document is indexed though.