Can Couchbase FTS be a better alternative to N1QL for querying large array fields in JSON documents?

We have a Couchbase bucket containing up to 20,000 documents. Each document includes around 10 array fields (e.g., userIds, clientIds, countryCodes, regions etc.), all of which are arrays of strings. Some of these arrays can grow up to 50,000 elements.

We frequently need to query these documents based on criteria within all the array fields in the documents. Using N1QL—even with appropriate indexing—takes around 2–3 seconds per query, likely due to the large size of some arrays. We have SLA of 50ms.

However, when we use Full Text Search (FTS) inverted indexes, the same queries return results in just a few milliseconds.

We’re considering whether to rely on FTS instead of refactoring the document structure to optimize N1QL performance.

Additional context:

  • There are a few hundred update/delete operations per day.

  • We’re concerned about long-term scalability and maintainability.

Question: Is using FTS a good approach for querying large array fields in Couchbase, or would it be better to restructure the documents to improve N1QL performance?

Search (FTS) indexes are made for these kind of use cases where you need to index large volume of text and arrays, applying various segmentation and tokenization algorithms and the index format will allow for very performant lookup - so would be an ideal solution for your use case.

They also support various other kinds of data like geospatial, vector etc. and will colocate these indexes alongside text indexes for several hybrid search use cases. See: Add Search to Your Application | Couchbase Docs

1 Like