Couchbase: Quering data bucket with Partial id.

Knoldus

Introduction:

In this article I am going to explain how to get documents from data bucket, if you only have partial Id, in other words using LIKE operation of Sql in couchbase by using Views of Couchbase.

For Example:

I have these four documents in my bucket, and I want to get all the documents having starting “abc”, then it must retrieve all the three documents.

Screenshot from 2015-07-07 13:36:18

Result must contain all the three documents :

abc::1, abc::2, abc::3

Then to implement this we can use the View functionality of Couchbase, and then we can fire the query on the view accordingly.

Step 1: Create view on the data bucket, by clicking on create Development View in View option.

Step 2 : Edit the function of view accordingly :

function (doc, meta) {
emit(meta.id,doc.name);
}

You can use different functions like emit() in this function accordingly and the list of functions can…

View original post 103 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s