How to add FTS index for Geo Search

I am trying to build a geo Index but in my case the the lat and long are stored in the Records.Address.Longitude and Records.Address.Latitude like below screen shot of part of my doc.

So my question is how can I go and use those 2 fields to generate a geo index when the input box does look like this ? I assume the Field would be Records.Address as it holds the Longitude and Latitude fields but how do i tell it the actual fieldnames as it is not lat and lon and how to avoid to store the whole address object vs only the lat lon ?


Couchbase’s full-text geo spatial support recognizes points of 3 formats only -

  • String: “latitude,longitude” or a geo-hash
  • Array : [longitude, latitude]
  • Object: {“lon” : 0.0, “lat”: 0.0},{“lng”: 0.0, “lat”: 0.0}

as documented here:

Seeing that you have separate fields “longitude” and “latitude”, you’ll need to index the geo point as an object. But that said, “lon”/“lng” and “lat” are the only recognized field names - so you’ll first need to model your data to reflect that.

Once that’s done, in your index definition you will need to setup a child mapping “Record” within the default mapping and a child field “Address” within “Record” as a geopoint type. This would automatically have your index look for “lat” and “lng”/“lon” within Record.Address fields of your documents.

For search, the field name you’ll need to now use is “Record.Address”.

Hope this helps.

As much as I like Couchbase the fact that you limit the name of the fieldnames is quite strange. In my case I get the Data from an data feed where these fields are preset and changing the name or structure of my doc is not that simple as i will have to change several mil records. Based on the option you list i think simplest way would be creating an additional key in my address and store the geo data. Is there any performance difference between these 3 as well any difference when storing a string or the geo-hash ?

None that we are aware of.

Lets say i chose the array option, does couchbase expect these to be numbers or strings ?

It’s all documented here - Geospatial Queries | Couchbase Docs

With an array, they’ll need to be numeric - floating point integers.