Search code examples
solrcassandradatastaxdatastax-enterprise

DSE: Geo location i.e latitude and longitude is stored as different fields in cassandra


I'm upgrading from Apache Cassandra to Datastax Cassandra. Planning to use the location search feature on one of my tables.

Current table looks something like below

CREATE TABLE tweets (
   id INT PRIMARY KEY,
   user TEXT,
   body TEXT,
   time TIMESTAMP,
   latitude FLOAT,
   longitude FLOAT
);

In the example Datastax Solr config, I see that latitude and longitude are expected to part of the same column. Is there a way where I can index latitude and longitude separately so that Solr can understand ?


Solution

  • I think that you can achieve this by using Field Input Transformer (FIT) - it allows to transform document that is submitted to Solr, so you can take both coordinates & create one single field from it. Please check the linked documentation - it has sample code, that shouldn't be very hard to implement.

    P.S. Instead of LatLong type you may look to RPT (RecursivePrefixTree) instead - it could be more efficient. I also have an example how this field type could be configured in DSE (although I'm using the DSE's PointType inside DSE Core).