Views, Indexing, and Index Service
Views and indexes support querying data in Couchbase Server.
Querying of Couchbase data is accomplished via the following:
MapReduce views accessed via the View API.
Spatial views accessed via the Spatial View API.
N1QL queries with Global Secondary Indexes (GSI) and MapReduce views.
Couchbase Server provides a number of indexes that can accelerate access for different types of queries.
- MapReduce view indexer
This incremental view indexer takes in a user defined map and reduce function and incrementally processes each mutation on the bucket and calculates a view.
Views are typically useful for interactive reporting type queries where complex data processing and custom data reshaping is necessary. Incremental MapReduce views are part of the data service and are partitioned across the nodes in the same way as the data. This means the view indexer always processes mutations from the local vBuckets.
You can query incremental MapReduce views using the view API. N1QL also allows access to MapReduce views, but only allows a static MapReduce function that cannot be altered.
For more information about MapReduce views, see Incremental MapReduce Views.
- Spatial view indexer
Spatial view indexer takes in a map function that supports processing geographic information and allows multidimensional bounding box queries for location aware applications.
Much like the MapReduce views, spatial views incrementally process each mutation on the bucket and calculate a spatial view. Spatial views are part of the data service and are partitioned across the nodes in the same way as the data. This means the spatial view indexer always processes mutations from the local vBuckets.
You can query spatial views using the spatial view API.
For more information, see Spatial Views.
- GSI indexer
The indexer for Global Secondary Indexes (GSIs) is similar to the B+tree indexers widely used in relational databases. GSIs index document attributes and N1QL-based expressions to provide a faster lookup with N1QL queries. GSIs are purpose-built for N1QL queries and can only be utilized through N1QL queries.
GSIs are a part of the index service and are independent of the data service. They are partitioned across the nodes independent of the data. This means the indexer for GSI typically does not always process mutations from the local vBuckets.
For more information, see Global Secondary Indexes (GSIs).
For a comparison between MapReduce views and Global Secondary Indexes, see Global Secondary Indexes Versus Views.