A newer version of this documentation is available.

View Latest

Full Text Search Reference

Couchbase Server Full Text Search (FTS) enables you to create, manage, and query full text indexes on JSON documents stored in a Couchbase bucket.

The Full Text Search feature is a Developer Preview version. This feature is considered experimental and the UI or the functionality may change.

Full Text Search provides powerful capabilities for querying natural language. There are three major benefits that make full text search much easier to use than alternative methods of querying, such as a wildcard match in N1QL using LIKE statements:

  • FTS provides a language-aware manner of searching, so users can type "beauties" and find results for "beauty" - which is not easy to do with regular expressions.

  • FTS provides scoring (relevance ranking) for results. Text search often returns massive numbers of matching documents, which are ordered by score so that users are presented with only a small number of results that are most likely to be the ones they are looking for. With regular expressions, there’s no practical way to simulate relevance.

  • FTS provides fast indexes that support a wide range of possible text searches. Regular expressions can be used to build one-off indexes but can’t be used to build indexes that support a full range of possible text searches.

Couchbase Server Full Text Search is powered by bleve, a full text search and indexing library written in Go. FTS indexes your documents with Bleve and lets you use Bleve’s many powerful query types:

  • Term, Phrase, Match, Match Phrase, Prefix

  • Conjunction, Disjunction, Boolean

  • Numeric and Date Ranges

  • Query String (see Syntax)

FTS includes Bleve’s general-purpose analyzers as well as pre-built text analyzers for the following languages: Danish, Dutch, English, Finnish, French, German, Hungarian, Italian, Norwegian, Persian, Portuguese, Romanian, Russian, Sorani, Spanish, Swedish, Thai, and Turkish.

FTS scores documents for relevance using Bleve’s industry standard tf-idf scoring with query time boosting.

Executing Your First Full Text Query

Full text search is a service that is installed by default and no special installation is necessary. Just make sure you enable the service when you provision your Couchbase Server node.

Creating Your First Full Text Index

  1. Log in to the Couchbase Web Console, for example, http://localhost:8091/.

    Click Indexes  Full Text, then click on the New Full Text Index button.

    A form where you can define your new index configuration is displayed.

  2. Each index needs a unique name. Type one in, such as "test-index". Only alphanumeric characters, hyphens, and underscores are allowed for index names. Also, the first character must be an alphabetic character.

  3. Choose a bucket from the drop-down list.

    There are more options, but you can ignore those for now and rely on the default values.

  4. Go! Finally, click the Create Index button.

    You should now see a summary page of your new full text index. The document count shows how many documents have been indexed so far. You can click on the Refresh button next to the Document Count field in order to see the indexing progress.

Querying Your Full Text Index

  1. Click on the Full Text tab again.

  2. From the drop-down list, select your newly created index.

  3. In the query field, type in a query term and press the Search button.

Congratulations, you’ve just executed your first full text query!

Using the Full Text Search REST API

You can also use the full text search REST APIs to access your index. For example, if your index is named myFirstIndex, here’s how you can use curl to check how many documents are indexed:

curl -u Administrator:password http://localhost:8094/api/index/myFirstIndex/count

Here’s an example of using curl to query the index myFirstIndex:

curl -X POST -H "Content-Type: application/json" \
          -d '{"size":10,"query":{"query":"your search string"}}' \

That’s it! You should be ready to explore, or read on to learn more about creating and querying indexes.

Also, you may want to take a look at the following blog that explains how the full text search API (experimental) is expressed using the Java SDK: https://blog.couchbase.com/cbftjavapreview/