Indexes
You have understood what a MapReduce program is and how it is used to create views in the Couchbase cluster. A view helps us to retrieve or search for a document by attributes of the document other than the document ID. In a database terminology, which is called an index, that enables to fetch documents using some look up mechanism, indexes help to search for a document in an efficient manner. As discussed earlier, MapReduce allows to create views/indexes on documents that is stored locally on each node. Index creation occurs in parallel in each node within the cluster. Finally, when clients query views, the results from all nodes are combined and provided to clients. Indexes and views are optimized for search and aggregations, which will be performed in the reduce
function. The output of the map
function is stored in a B-tree format, to enable fast retrieval. Whenever you want to fetch documents using attributes of documents, you can create views, which in turn will create indexes...