Do I need indexes on all my index servers?

Hi,

Let’s say I have two index servers. Do I need to create indexes on both of them with a different index name for the same field?

Server A: idx_test_a
Server B: idx_test_b

answering your title: you don’t need to have indexes on all index service nodes.
you can create and distribute your indexes across to all nodes - look at the WITH clause here for placement of indexes.
http://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-language-reference/createindex.html

I think I don’t fully understand how WITH clause works.

I have two index servers.

create index tmp_idx on mybucket(fqid) where form='attribute' using gsi with {"nodes": ["ip1", "ip2"]}

I get the following error message.

GSI CreateIndex() - cause: Create Index is allowed for one and only one node"

When I just give it one single IP,

create index tmp_idx on catalog(fqid) where form='attribute' using gsi with {"nodes": "ip1"}

Then I only see the index on that IP in the admin console.

FYI.
I think you can create index on both nodes by:

create index tmp_idx1 on catalog(fqid) where form='attribute' using gsi with {"nodes": "ip1"}

create index tmp_idx2 on catalog(fqid) where form='attribute' using gsi with {"nodes": "ip2"}

Hi,

Yes, I can.

I was wondering if it is necessary or not.

The one scenario where it’s necessary is if you want to have high availability in the event of a failure. Beyond that, it may be needed for performance, but that’s a question of workload. Other than creating a second one for availability purposes and monitoring stats, I’d just recommend starting simple.

1 Like

I’m new to couchbase, we are using couchbase 6.0(community edition)
We have a 3 node cluster and I’m trying to create indexes on all the nodes for high availability. I’m getting this below error

Query:
create index XXXXXX on XXXXXX where id=XXXXXXXXXXXX using gsi with {“nodes”: “XX.XX.XX.XX”}

Error:

[
{
“code”: 3000,
“msg”: “syntax error - at where”,
“query_from_user”: “create index XXXXX on XXXXXX where id=XXXXXXXXXXXX using gsi with {“nodes”: “XX.XX.XX.XX”}”
}
]

Can someone guide me in right path

Thanks in Advance

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/createindex.html

9. Duplicate Index