How to create advanced indexes using Go SDK

Hi there,

I’m trying to automate the index creation using the GO SDK. This works well for simple indexes like:

CREATE INDEX some_idx ON mybucket (field1, field2)
err = queryIdxMgr.CreateIndex(bucketname, "some_idx", []string{"field1", "field2"}, &gocb.CreateQueryIndexOptions{
			IgnoreIfExists: false,

But how can I create an index like this:

CREATE INDEX `login_identity_tenantid_1` ON `bucketname`((distinct (array (distinct (array (`mft`.`tenant_id`) for `mft` in (`cred`.`main_for_tenant`) end)) for `cred` in `credentials` end))) WHERE (`type` = "identity")

Is that even supported?

Hi @Frank_Lyner the index management API isn’t designed for more advanced use cases so doesn’t support what you’re trying to do. You can still create your index using the Query function at cluster level though.

1 Like