Punter Vicky
Punter Vicky

Reputation: 17032

Java Couchbase SDK - Query without Views

I have couchbase DB deployed in production. I want to write java code to query few details. It doesn't have any views as of today and in order to have views created , I need to go through a lot of process. Is there a way to run queries using code written in couchbase java sdk or is it mandatory get views created to run custom queries.

Upvotes: 0

Views: 88

Answers (1)

Simon Baslé
Simon Baslé

Reputation: 28351

If you're using Couchbase 4.0 or above, you can use N1QL. Create at least a primary N1QL index once, query anything... You can even create more specific N1QL secondary indexes tailored for queries for which you need better performance.

Views are very specific, they force you to think about exactly how you'll query your data and limit you to that use case. N1QL on the other hand is very general purpose. It's a superset of SQL, with JSON-specific additions.

Of course both work on the assumption that your data is JSON

Without view nor N1QL, you're limited to requests using the keys of documents, which you must know in advance (but that could be a usable alternative nonetheless, eg. if keys are mentioned in another document, or can be reconstructed from the content of another document of which you know the key).

Upvotes: 2

Related Questions