A newer version of this documentation is available.

View Latest

Full Text Search: Fundamentals

    +
    Full Text Search (FTS) lets you create, manage, and query specially purposed indexes, defined on JSON documents within a Couchbase bucket.

    Full Text Search provides Google-like search capability on JSON documents. Couchbase’s Global Secondary Indexes (GSI) can be used for range scans and regular pattern search, whereas FTS provides extensive capabilities for natural-language querying. The query below looks for documents with all of the strings ("paris", "notre", "dame").

    {
      "explain": false,
      "fields": [
        "*"
      ],
      "highlight": {},
      "query": {
        "query": "+paris +notre +dame"
       }
    }

    This query returns the following result (shown partially) from the FTS index scan on the travel-sample sample bucket. For each matched document, the hits field shows the document id, the score, the fields in which a matched string occurs, and the position of the matched string.

    "hits": [
        {
          "index": "trsample_623ab1fb8bfc1297_6ddbfb54",
          "id": "landmark_21603",
          "score": 2.1834097375254955,
          "locations": {
            "city": {
              "paris": [
                {
                  "pos": 1,
                  "start": 0,
                  "end": 5,
                  "array_positions": null
                }
              ]
            },
            "content": {
              "dame": [
                {
                  "pos": 23,
                  "start": 169,
                  "end": 173,
                  "array_positions": null
                },
    ...
    ]

    Examples of natural language support include:

    • Language-aware searching; allowing users to search for, say, the word beauties, and additionally obtain results for beauty and beautiful.

    • Multiple pre-constructed language analyzers to enable language aware searches upto 20 languages.

    • Scoring of results, according to relevancy; allowing users to obtain result-sets that only contain documents awarded the highest scores. This keeps result-sets manageably small, even when the total number of documents returned is extremely large.

    • Fast indexes, which support a wide range of possible text-searches.

    Full Text Search is powered by Bleve, an open source search and indexing library written in Go. Full Text Search uses Bleve for the indexing of documents, and also makes available Bleve’s extensive range of query types. These include:

    Full Text Search includes pre-built text analyzers for the following languages: Arabic, CJK characters (Chinese, Japanese, and Korean), English, French, Hindi, Italian, Kurdish, Persian, and Portuguese. Additional languages have been added to Couchbase Server 5.5.

    To access Full Text Search, users require appropriate roles. The role FTS Admin must therefore be assigned to those who intend to create indexes; and the role FTS Searcher to those who intend to perform searches. For information on creating users and assigning roles, see Authorization.