SDK: 2.7.9
Couchbase server: 5.5 Enterprise
Hello,
I would like to create my secondary index using the SDK. So I use the BucketManager
function:
createN1qlIndex(String indexName, List fields, Expression whereClause, boolean ignoreIfExist, boolean defer, long timeout, TimeUnit timeUnit).
But I want my index to have replica. Unfortunatly, the number of replica cannot be set with any SDK function.
Why does “num_replica” parameter is missing in this function?
Is it normal? Is it an omission? a bug? …
This is forcing me to transform my index definition into a String and to use a N1ql query. In my opinion, this way is not reliable in order to simply add the parameter “num_replica”…
I don’t want neither to use the curl command as the number of replica has to be dynamic.
Could you tell me how to create secondary index with replica parameter using the SDK?
Thank you.
Christophe
Hi Christophe,
Why does “num_replica” parameter is missing in this function?
Is it normal? Is it an omission? a bug? …
It’s an omission that we’re addressing with the new query index management API in Java SDK 3.0 (currently in alpha).
This is forcing me to transform my index definition into a String and to use a N1ql query. In my opinion, this way is not reliable in order to simply add the parameter “num_replica”…
This is exactly what the SDK does behind the scenes. The Java API is just a convenience layer that builds and executes the N1QL query for you. Unfortunately, building the index creation statement by hand is currently the only way to set the num_replica
parameter as of SDK 2.7.9.
I sympathize with you; it’s a pain to have to do it this way. If I had to guess, I’d say the reason this option was originally omitted from the Java API is that we didn’t anticipate people using the API outside of simple integration test scenarios, where replicating the index is not as important. But now we know better, and will be supporting it in SDK 3.0.
2 Likes