user396404
user396404

Reputation: 2819

Querying any field in a bucket in Couchbase

Is it possible to setup a bucket in Couchbase such that I can query it by any field? Or, by the subvalue for a field. For example, if I have a bucket with document such as:

{
    name: 'Acme Corp',
    revenue: 1000000,
    other: {
       location: 'NY',
       popularity: 50
    }
}

I would like to be able to run a query such as:

SELECT * FROM `records` where revenue > 100 AND other.popularity > 20

This is a simplified example and in reality, there might be dozens of other fields (and sub fields) which I'd like to be able to query without indexes (I don't mind the full scan). Please note that this question is not a discussion about whether or not it is a good idea to do something like this. It's about if something like this is possible.

Upvotes: 0

Views: 58

Answers (1)

EbenH
EbenH

Reputation: 566

Yes, you can query on any field, as long as there is either: 1) a primary index on the bucket (which results in a slow full scan), or, 2) an index on the field in question (which permits a faster index scan).

Upvotes: 1

Related Questions