MapReduce questions

I'am new to MapReduce, using the Java 1.1.9 SDK

 
View view = client.getView("beer", "brewery_beers");

It is possible to pass object/variable to view (map reduce)?
view.setValue() ?

Thank you in advance.

1 Answer

« Back to question.

Hello,

I will try to clarify the way Map/Reduce is used inside Couchbase.

Map/Reduce are called "Views" inside Couchbase and they are used to index your document : take some attributes from your JSON Documents and create an index that you can then query.

The Map is only executed when you save/update a document, and Couchbase Server sends the document and the metada to the function. So here you cannot control what is sent to the map/reduce. Remember that you do not control when this is called, it is done by the server to index the document added/updated in Couchbase.

The Java code you are showing is used to call the view,... let me explain what that means.

View view = client.getView("beer", "brewery_beers"); 

This does not call the Map/Reduce... it only prepares the object to do a Query on the index that is created by the map reduce.

So you can pass parametes to the Query to select the rows from the index, the list of parameter you can uses is available here:
- Finding Data with Views
- Java View Query Interface

Hope that helps, and do not hesitate to ask for more information if this is not enough for you.

More Advanced Content:
If you want to know exactly when the Map/reduce functions are called in Couchbase you can look in this chapter Index Updates and the stale Parameter

Regards
Tug
@tgrall