November 2015
Beginner to intermediate
248 pages
5h 24m
English
A Couchbase bucket can also store two-dimensional spatial records specifying longitude and latitude. If you want to create a view for spatial records, it can be done using a geospatial view. This is introduced as an experimental feature and can be used in the development environment only. You can refer to the documentation for any update on this.
The following document represents the location of the city, Mumbai, in the bucket:
{
"location" : 18.9750, 72.8258],
"city" : "Mumbai"
}You can create geospatial view as follows:
function(doc, meta)
{
if (doc.loc)
{
emit( { type: "Point", coordinates: doc. location, }, doc.location);
}
}The key in the spatial view index can be any valid GeoJSON geometry value.
Read now
Unlock full access