1

As I saw in Couchbase documentation it's possible to create an index for the particular fields of a document: https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/createindex.html

CREATE INDEX country_idx ON `travel-sample`.inventory.airport(country, city)
WITH {"nodes": ["node1:8091", "node2:8091", "node3:8091"]};

Is it possible to create an index for all available fields just like GIN in PostgreSQL?

There is a statement in the section about Community-edition limitations:

In Couchbase Server Community Edition, a single global secondary index can be placed on a single node that runs the indexing service.

Could this "global index" be what I'm looking for? If so how I can create it?

P.S. This one-node limitation doesn't make a sense for me to be honest, even for community edition. What is the point to use the system that can't scale if scalability is its purpose? Maybe I got it wrong?

Sogawa-sps
  • 147
  • 10
  • "global secondary index" means that indexes are not stored alongside the data they are indexing; they can be accessed globally (which is more efficient for scaling than the "scatter/gather" alternative. I think the closest equivalent to "GIN" is called an "adaptive index" in Couchbase - https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/adaptive-indexing.html#examples - specifically `DISTINCT PAIRS(self)`, but note that performance might not be as good as more specific indexes (which I would guess is also true of GIN) – Matthew Groves Sep 08 '21 at 13:45
  • Thank you @MatthewGroves. Adaptive index seems to be exactly what I need. And I got the idea of GIS as well, now it's clear. But still there is that one-node limitation for community edition :(. As it was advised by vsr in the answer this limitation can be bypassed via duplicate indexes, will check. – Sogawa-sps Sep 08 '21 at 19:25

1 Answers1

2

By default couchbase GSI index is called Global secondary index (Even though data distributed across different data nodes, index will have data from the all the nodes).

Above statement means Community Edition will not support partition index or number of replica index (replica can be over come by creating duplicate index i.e. index with same definition with different name, during execution it will load balance the index scans).

As far as all the fields of the document check out adaptive index, but better performance create targeted indexes.

checkout 8 & 9 https://blog.couchbase.com/create-right-index-get-right-performance/

vsr
  • 7,149
  • 1
  • 11
  • 10
  • Thanks a lot! Adaptive index looks very similar to GIN indeed. Duplicate indexes seem like an interesting workaround, but I am wondering if it won't be too burdensome. – Sogawa-sps Sep 08 '21 at 19:28
  • duplicate indexes not burden. replicas (EE) is auto managed, duplicate index is manually managed. It also does load balance. i.e During start of scan it detects underneath index definition is same and choose that index if system is less loaded. – vsr Sep 08 '21 at 22:33
  • checkout 8 & 9 https://blog.couchbase.com/create-right-index-get-right-performance/ – vsr Sep 08 '21 at 22:39