Couchbase Server (A.K.A. Couchbase) is open source, NoSQL, document oriented database that stores JSON documents. Couchbase has recently introduced a new feature - Full Text Search (FTS). This feature is currently a Developer Preview Version (as of Aug 24, 2017). Couchbase has provided decent documentation for FTS which can be access here.
Couchbase stores all the JSON documents in a Bucket. Using N1QL, you can query these documents. These queries are more like SQL statements but for JSON. On the other hand, with FTS you can use following powerful query types:
In order to use FTS feature, we need to make our bucket searchable by defining search index. This can be done using Couchbase Console or by executing CURL command. For example, we will be creating multiple indexes based on a JSON field: type. You can use any field from your JSON document. If this field is present in each JSON document, then that is even better.
To create search index for “user”, we will perform following steps:
Since Couchbase FTS feature is currently (as of Aug 24, 2017) "experimental", the functionality can change in future.
P.S. Click here to access my other posts.
Couchbase stores all the JSON documents in a Bucket. Using N1QL, you can query these documents. These queries are more like SQL statements but for JSON. On the other hand, with FTS you can use following powerful query types:
- Term, Phrase, Match, Match Phrase, Prefix
- Conjunction, Disjunction, Boolean
- Numeric and Date Ranges
- Query String
In order to use FTS feature, we need to make our bucket searchable by defining search index. This can be done using Couchbase Console or by executing CURL command. For example, we will be creating multiple indexes based on a JSON field: type. You can use any field from your JSON document. If this field is present in each JSON document, then that is even better.
To create search index for “user”, we will perform following steps:
- Login to Couchbase Web Console with admin credentials
- Select Indexes >> Full Text >> New Full Text Index
- Provide name of the index: fts-user-index
- Select the bucket
- Select JSON type field as Type Identifier and provide field name: type
- Select Type Mappings >> Add Type Mapping
- Enter name as: user
- Dropdown value should be “inherit”, enabled check box is checked and only index specified field checkbox is unchecked
- Click OK to create type mapping for user
- Go to “default” type mapping and click on edit
- Uncheck enabled check box and click OK
- Click on “Create Index” button
Since Couchbase FTS feature is currently (as of Aug 24, 2017) "experimental", the functionality can change in future.
P.S. Click here to access my other posts.
Comments
Post a Comment