ibm-cloud-docs / Cloudant

11 stars 48 forks source link

Views vs Search Indexes #4

Closed MarcWadai closed 6 years ago

MarcWadai commented 6 years ago

I had some difficulties understanding the differences between a views and a search indexes. For exemple, they both are based on javascript functions but one use emit and the other index to return the result.

So when should we need to use views / Search indexes or Query ?

Is there some more documentation in which I could dig in ?

Thanks ! (Sorry if this is not the right places to ask those questions)

lbboe commented 6 years ago

Hello Marc,

I apologize for the delay in responding. Here is a response to your questions:

If you want a range of results from your documents, you use views. For example, you use views when you have a field in your documents called age, and you want to find all documents where the age is between 5 and 15.

If you want to find a specific value, you use search. For example, you use search when you have an 'address' field in your documents, and you want to find documents where the field contains 'california'.

Now, you can modify your view and search indexes to search for a range of results or for a specific field, but range queries are more efficient with views, and specific searches are more efficient with search. Cloudant Query is a wrapper on top of views and search. It provides an interface for users so they don't have to write Javascript.

Here are links to relevant documentation:

Views

Search

Thank you for your questions. Again, I apologize for the delay.

Best regards, Lora