Partial index creation (where condition) in Couchbase Java SDK 3.0

How to create partial index (with where condition in the index) by using Couchbase Java SDK 3.0?

I was referring the below for the & from the below link. I couldn’t see any op[tion to include where clause.

1 Like

Hi Ramesh,

I looked at the Index manager API and I don’t see a way to specify a WHERE clause. Thanks for reporting this omission. I’ve filed JCBC-1629 to track the issue.


Hi Ramesh,
I’ve since learned that the omission is intentional. Apparently there are a great many options for index creation, and it was decided that the index management API should only support the most common options.

The good news is that it’s relatively easy to create an index using the Query API. (In fact, the Index Management API uses the Query API behind the scenes). Here’s the documentation for the CREATE INDEX query command:


Hi David,

I feel that we should not restrict functionality in Java SDK. You can keep it in CreateQueryIndexOptions, or make a separate function which adds whereCondition. To keep it simple, you can ask for a String in either of the places, so that you don’t have to do a lot of pipelining.

There are two points in what you have mentioned:

  • Scopes and collections are only there in 7.x that is not stable yet
  • Even with 7.x inclusion, some usecases might prefer having the conditional query
    • In my own usecase, I have a lot of indexes with different where conditions
    • I don’t want to create different scopes and collections for each where condition

I feel it would be great if this is included in the latest release.