{"id":9025,"date":"2020-08-12T09:00:13","date_gmt":"2020-08-12T16:00:13","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=9025"},"modified":"2025-06-13T20:27:37","modified_gmt":"2025-06-14T03:27:37","slug":"announcing-flex-index-with-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/","title":{"rendered":"Announcing Flex Index With Couchbase"},"content":{"rendered":"<h2><span style=\"font-weight: 400\">Flex Index Explained<\/span><\/h2>\n<p><span style=\"font-weight: 400\">What is a Flex Index? One of the key tasks of a database engine is how to efficiently manage the search and retrieval of the data therein. The efficiency and balance between resource consumption and performance are the most critical aspects of any database. Different types of database indexes, e.g. B-Tree, Inverted, Graph, and Spatial, etc., are designed to meet different search requirements. While indexes are essential for search performance, choosing the appropriate index type to use can also make a big difference to their effectiveness. Because the best type of indexes are often dictated by the characteristic of the data element being indexed.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">In Couchbase,\u00a0 Global Secondary Index uses a B-Tree structure for fast exact and range search, and Full Text Search uses the inverted index structure to provide efficient term search.\u00a0 In addition to being highly scalable, each of these types of index also offers its own unique capabilities. B-Tree is the most commonly used index for high selectivity values (i.e. more distinct, such as order number), while inverted indexes are best used for indexing textual content, where the searchable term is likely to have low selectivity.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Applications that interface directly with users need search capability, and more often than not, these applications require both exact search, as well as text search. These search capabilities are often available through different search services, and as separate search APIs, which in turn can increase the complexity of the application development.<\/span><\/p>\n<p><span style=\"font-weight: 400\">To address this need, Couchbase introduced the N1QL SEARCH() function in v6.5. It allows N1QL query to use both SQL predicate for exact and range search, and SEARCH() for text search, where results are not only predicated by the search term, but also by its relevance score. This adds a fuzziness factor to the search, as well as language aware capabilities.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The N1QL SEARCH() feature, for the first time, allows applications to access both query search services from a single API, using the Couchbase N1QL language. This integration offers many advantages. Chief among them is the simplification of the application development process by not having to deal with different APIs, but also delegating more of the search processing to the back end services.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">In Couchbase 6.6, we took this N1QL\/FTS integration one step further with<\/span><b> Couchbase Flex Index<\/b><span style=\"font-weight: 400\">.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">What is Flex Index?<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Flex index is a capability for Couchbase query service to leverage search capabilities, using only the standard N1QL predicate. Meaning you do not need to use the FTS syntax, nor the SEARCH() function, for your N1QL query to leverage FTS indexes.\u00a0<\/span><\/p>\n<p>The search datatype support includes text, datetime, numeric and boolean. But for text, only the keyword search is supported.<\/p>\n<p><b>Keyword search &#8211;<\/b><span style=\"font-weight: 400\"> refers to the way a text field is processed before adding to an index. FTS index using the <code>standard<\/code> analyzer would parse the text into individual terms before indexing, whereas the <code>keyword<\/code> analyzer uses the entire text for the index.<\/span><\/p>\n<p><span style=\"font-weight: 400\">So to understand how Flex Index works, let&#8217;s say that you have a query with this search condition:\u00a0 To find all the activities in a sales activity management system where the activities had involved the customer \u201cHorizon Communications\u201d, and happened in\u00a0 August 2020, and took place during a marketing event at the Moscone Center.\u00a0<\/span><\/p>\n<pre class=\"lang:pgsql decode:true\">SELECT * FROM crm\u00a0\r\n\u00a0 WHERE type='activity'\r\n\u00a0 \u00a0 AND event.location = 'Moscone Center'\r\n\u00a0 \u00a0 AND account.name = 'Horizon Communications'\r\n\u00a0 \u00a0 AND act_date BETWEEN '2020-08-01' AND '2020-08-31'<\/pre>\n<p><span style=\"font-weight: 400\">Assume also that you have this GSI index :\u00a0<\/span><\/p>\n<pre class=\"lang:pgsql decode:true \">CREATE INDEX adv_account_name_event_site_actdate\r\nON `crm`(`account`.`name`,`event`.`location`,`act_date`)\r\n\u00a0 \u00a0 WHERE type='activity'<\/pre>\n<p>This query, as it is written, will leverage the above GSI index because:<\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">All query predicates are covered by the index.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The query also has the predicate <code>type<\/code>=&#8217;activity&#8217; that matches the filter of the index.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">In fact, the index will be considered as long as the leading key `account`.`name` is one of the predicates, and that the query is restricted to <code>type<\/code>=&#8217;activity&#8217;.<\/span><\/li>\n<\/ol>\n<h5>Query Plan:<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9026\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.08.35-PM.png\" alt=\"\" width=\"937\" height=\"104\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.08.35-PM.png 937w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.08.35-PM-300x33.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.08.35-PM-768x85.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.08.35-PM-20x2.png 20w\" sizes=\"auto, (max-width: 937px) 100vw, 937px\" \/><\/p>\n<p><span style=\"font-weight: 400\">With<\/span><b> Flex Index<\/b><span style=\"font-weight: 400\">, you now have the option to request the query service to consider using the FTS index for the query.\u00a0<\/span><\/p>\n<pre class=\"font:monospace lang:default decode:true\">SELECT * FROM crm  USE INDEX (USING FTS)\r\n   WHERE type='activity'\r\n     AND event.site = 'Moscone Center'\r\n     AND account.name = 'Horizon Communications' \r\n     AND act_date BETWEEN '2020-08-01' AND '2020-08-31'<\/pre>\n<p><span style=\"font-weight: 400\">The addition of the \u201c<\/span><b>USE INDEX (USING FTS)<\/b><span style=\"font-weight: 400\">\u201d hint suggests to the query service to consider using any FTS index, if one is available that can help with the query.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">And if you have an FTS index defined as below:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9028\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.13.31-PM.png\" alt=\"\" width=\"532\" height=\"448\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.13.31-PM.png 532w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.13.31-PM-300x253.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.13.31-PM-20x17.png 20w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/p>\n<p><span style=\"font-weight: 400\">The `a<\/span><span style=\"font-weight: 400\">ct_search`<\/span><span style=\"font-weight: 400\">\u00a0index has the following definition:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">It has a `type` mapping that restricts the index content to include only the documents of <code>type<\/code> = &#8216;activity&#8217;.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">It includes the child field <code>act_date<\/code>.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">It includes the two child mappings for <code>account<\/code> and <code>event<\/code> objects.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Note that it uses the <code>keyword<\/code> analyzer.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">In this case, the <\/span><span style=\"font-weight: 400\">`act_search` <\/span><span style=\"font-weight: 400\">is a perfect fit for the above N1QL Query, and with the<\/span> <b>USE INDEX (USING FTS)<\/b> <span style=\"font-weight: 400\">hint, the query will be able to use the <\/span><span style=\"font-weight: 400\">`act_search`<\/span><span style=\"font-weight: 400\"> FTS index.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Query Plan:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9029\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.16.51-PM.png\" alt=\"\" width=\"898\" height=\"87\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.16.51-PM.png 1053w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.16.51-PM-300x29.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.16.51-PM-1024x99.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.16.51-PM-768x74.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.16.51-PM-20x2.png 20w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/p>\n<p><span style=\"font-weight: 400\">So in a nutshell, <strong>Couchbase Flex Index<\/strong> provides the ability for N1QL Query with standard N1QL predicate syntax to transparently leverage either GSI or FTS index <\/span><b><i>without any modification to the N1QL statements<\/i><\/b><span style=\"font-weight: 400\">.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">But the value of Flex Index comes not only with the simpler syntax for using FTS, but also the versatility of the FTS index, some of which will be described in the subsequent sections.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">So when should you use Flex Index?<\/span><\/h2>\n<p><span style=\"font-weight: 400\">At the high level, <strong>Flex index<\/strong> can solve\u00a0 many challenges often found in applications that provide searches.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Where the search conditions of the N1QL statements are not predetermined, meaning they can contain varied numbers of predicates, often based on user&#8217;s selections. And it is difficult to create indexes to cover all of the search conditions..<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Applications that provide search capabilities involving a large number of predicates, with logical operators, such as\u00a0 AND\/OR combinations in the search conditions.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Where the search conditions involve predicates on hierarchical document elements, such as search that involve array\u00a0 elements in an array, or in multiple arrays.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Where the applications require the power of FTS, but also need SQL aggregation, and JOIN to include related information from other objects.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Or you simply want to use the N1QL predicate syntax over the FTS syntax.<\/span><\/li>\n<\/ol>\n<p><strong><em>Note that Flex Index can also be used retrospectively on existing applications by adding the `use_fts` parameter to the query API calls.\u00a0<\/em><\/strong><\/p>\n<h3><span style=\"font-weight: 400\">1) The search patterns are not predetermined<\/span><\/h3>\n<p><span style=\"font-weight: 400\">When it comes to providing search capability to the end users, the challenge has always been\u00a0 what you would allow the user to search on. Standard guidelines dictate that the decision be determined by the users&#8217; needs. But in complex systems, where the searchable fields are often not limited to a few key fields, but can encompass all the fields in an object, the decision on search is often driven by what the underlying database system can support.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Applications that are based on traditional B-Tree index for fast lookup often fall short when it comes to providing a flexible framework for this type of search requirement.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Consider this document:<\/span><\/p>\n<pre class=\"lang:js decode:true\">\"activity\" : {\r\n\u00a0 \"id\": \"act1000\",\r\n\u00a0 \"title\": \"Announcing Couchbase Flex Index CB6.6\",\r\n\u00a0 \"reference\": \"24-i2y5J3928\",\r\n\u00a0 \"dept\": \"st55\",\r\n\u00a0 \"region\": \"00528\",\r\n\u00a0 \"notes\": \"Review the 100 N1QL Flex Index queries that ElasticSQL cannot do. The important point here is that Couchbase has integrated Text Search capability into its N1QL. Whereas ElasticSearch, relatively new SQL, has added SQL to its search engine....\",\r\n\u00a0 \"owner\": {\r\n\u00a0 \u00a0 \"id\": \"usr24\",\r\n\u00a0 \u00a0 \"name\": \"John Higgins\"\r\n\u00a0 },\r\n\u00a0 \"priority\": \"Medium\",\r\n\u00a0 \"act_type\": \"Appointment\",\r\n\u00a0 \"event\": {\r\n\u00a0 \u00a0 \"name\": \"N1QL Flex Index vs. ElasticSQL\",\r\n\u00a0 \u00a0 \"location\": \"Moscone Center\",\r\n\u00a0 \u00a0 \"theme\": \"CouchbaseRed\",\r\n\u00a0 \u00a0 \"vendor\": \"Kempinski\"\r\n\u00a0 },\r\n\u00a0 \"account\": {\r\n\u00a0 \u00a0 \"id\": \"acc134\",\r\n\u00a0 \u00a0 \"name\": \"Horizon Communications\"\r\n\u00a0 },\r\n\u00a0 \"act_date\": \"2020-08-06\",\r\n\u00a0 \"appointment\": {\r\n\u00a0 \u00a0 \"duration\": 90,\r\n\u00a0 \u00a0 \"start_date\": \"2020-08-06 11:00:00\",\r\n\u00a0 \u00a0 \"contacts\": [\r\n\u00a0 \u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"id\": \"contact2493\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"title\": \"SalesRep\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"name\": \"Miranda Sullivan\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"email\": \"msullivan@horizoncell.com\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"phone\": \"778-096-1351\"\r\n\u00a0 \u00a0 \u00a0 }\r\n\u00a0 ],\r\n\u00a0 \"participants\": [\r\n\u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \"role\": \"Support Analyst\",\r\n\u00a0 \u00a0 \u00a0 \"userid\": \"usr57\",\r\n\u00a0 \u00a0 \u00a0 \"name\": \"Raven Peterson\"\r\n\u00a0 \u00a0 },\r\n\u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \"role\": \"Product Specialist\",\r\n\u00a0 \u00a0 \u00a0 \"userid\": \"usr24\",\r\n\u00a0 \u00a0 \u00a0 \"name\": \"John Higgins\"\r\n\u00a0 \u00a0 }\r\n\u00a0 ],\r\n\u00a0 \"type\": \"activity\"\r\n}<\/pre>\n<p>The 13 highlighted fields are all the possible fields that the user may want to search. So what would be the index strategy if you want to provide users with search capability?<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Index Strategy<\/b><\/td>\n<td><b>Pros<\/b><\/td>\n<td><b>Cons<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Create 13 individual indexes<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-Efficient for single field search.\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-If more than one field is in the search then multiple indexes will be used, resulting in intersection-scans, which will affect performance<\/span><\/p>\n<p><span style=\"font-weight: 400\">2-Increasingly inefficient as more search fields are included<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Create composite index for frequently used search combinations<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-Fast response time<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-Inflexible as only specific search combinations are supported.<\/span><\/p>\n<p><span style=\"font-weight: 400\">2-App UI has to ensure that the index leading key is present.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Create composite index for all search combinations<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-Fastest response time<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-The total\u00a0 number of indexes (13!) would be impractical<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Leverage Search Engine &#8211; ElasticSearch or Couchbase FTS<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-Fast response time<\/span><\/p>\n<p><span style=\"font-weight: 400\">2-Only a single index is required<\/span><\/td>\n<td><span style=\"font-weight: 400\">1-Need to rewrite the application to leverage the search engine<\/span><\/p>\n<p><span style=\"font-weight: 400\">2-More complex application code<\/span><\/p>\n<p><span style=\"font-weight: 400\">3-Maintenance cost<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">From the above list of options, it is clear that the most flexible search capability will require using a search engine, something similar to ElasticSearch or Couchbase FTS. But unless you have developed your application specifically with these search engines in mind, the effort to convert the search syntax and change of APIs will not be trivial.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">And this is where the value of Couchbase Flex Index comes into the picture.\u00a0 This new feature allows developers to write N1QL Query statements using standard N1QL predicates, and the Query service will transparently leverage the FTS index.<\/span><\/p>\n<h3><span style=\"font-weight: 400\">2) Query with any predicate combinations<\/span><\/h3>\n<p><span style=\"font-weight: 400\">One of the key differences between GSI B-Tree and FTS Text index is how the key fields are built. The GSI B-Tree index concatenates all of the key fields of the index together to make up the node key, which is the main reason why a leading key must be present in the query before the index can be considered. The FTS index, on the other hand, creates a separate inverted index for each field. This design allows an FTS index to be considered for any query that has at least one of the indexed fields.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Consider the following query which has 13 different predicates, as well as the `type`=&#8217;activity predicate.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:pgsql decode:true\">SELECT * FROM crm a\r\nWHERE a.type='activity'\r\n\/* 1\u00a0 *\/ AND a.title LIKE 'Announcing Couchbase Flex Index%'\r\n\/* 2\u00a0 *\/ AND a.dept = 'st55'\r\n\/* 3\u00a0 *\/ AND a.region = '00528'\r\n\/* 4\u00a0 *\/ AND a.priority = 'High'\r\n\/* 5\u00a0 *\/ AND a.act_date BETWEEN '2020-08-01' AND '2020-08-31'\r\n\/* 6\u00a0 *\/ AND a.event.location = 'Moscone Center South'\r\n\/* 7\u00a0 *\/ AND a.event.name = 'N1QL Flex Index vs ElasticSQL'\r\n\/* 8\u00a0 *\/ AND a.event.vendor = 'Kempskinki'\r\n\/* 9\u00a0 *\/ AND a.event.theme = 'CouchbaseRed'\r\n\/* 10 *\/ AND a.account.id = 'acc134'\r\n\/* 11 *\/ AND a.account.name = 'Horizon Communications'\r\n\/* 12 *\/ AND a.owner.id = 'usr24'\r\n\/* 13 *\/ AND a.owner.name = 'John Higgins'<\/pre>\n<p><span style=\"font-weight: 400\">To get the best performance, you need to have an index for the query, and the best index to have is a covering index as given by ADVISE:<\/span><\/p>\n<pre class=\"lang:pgsql decode:true \">CREATE INDEX adv_idx13 ON crm`\r\n(`account`.`name`,`event`.`vendor`,`account`.`id`,`event`.`location`,\r\n `event`.`theme`,`priority`,`owner`.`name`,`dept`,`event`.`name`,\r\n `owner`.`id`,`region`,`act_date`,`title`) \r\nWHERE `type` = 'activity'\r\n<\/pre>\n<h5><span style=\"font-weight: 400\">Query Plan:<\/span><\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9030\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.30.38-PM.png\" alt=\"\" width=\"989\" height=\"105\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.30.38-PM.png 989w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.30.38-PM-300x32.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.30.38-PM-768x82.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.30.38-PM-20x2.png 20w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/p>\n<h5><span style=\"font-weight: 400\">However what would happen if:<\/span><\/h5>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The query does not have the leading key `account`.`name`?<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The query has a varying combination of the 13 predicates?<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">GSI is the best index to have, providing you know the exact query predicates. However for applications that need to provide support for ad hoc queries, where the predicate set can not be predetermined, then it is best to consider using FTS.<\/span><\/p>\n<p><span style=\"font-weight: 400\">So let&#8217;s now consider the following FTS index.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9031\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.32.18-PM.png\" alt=\"\" width=\"810\" height=\"850\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.32.18-PM.png 810w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.32.18-PM-286x300.png 286w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.32.18-PM-768x806.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.32.18-PM-300x315.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.32.18-PM-20x20.png 20w\" sizes=\"auto, (max-width: 810px) 100vw, 810px\" \/><\/p>\n<h5><span style=\"font-weight: 400\">Notes:<\/span><\/h5>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The index contains a `type` mapping to specify that only documents with the `type` = &#8216;activity&#8217; will be included in the index. Refer to this <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/fts\/fts-creating-indexes.html#specifying-type-identifiers\"><span style=\"font-weight: 400\">FTS type mappings<\/span><\/a><span style=\"font-weight: 400\"> documentation for more information.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The index uses the keyword analyzer, meaning the data value will be added to the index in its entirety without getting parsed into individual terms.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Each field is indexed individually in much the same way as the GSI index. <\/span><span style=\"font-weight: 400\">All other options are unchecked, as they are not relevant to keyword search. Refer to this <a href=\"https:\/\/docs.couchbase.com\/server\/current\/fts\/fts-creating-indexes.html#inserting-a-child-field\">FTS child mapping<\/a> documentation for more information.\u00a0<\/span><span style=\"font-weight: 400\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9032\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.33.32-PM.png\" alt=\"\" width=\"555\" height=\"25\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.33.32-PM.png 555w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.33.32-PM-300x14.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.33.32-PM-20x1.png 20w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">With this FTS index in place, the same query as above, but with the <\/span><b>USE INDEX (all_acts USING FTS) <\/b><span style=\"font-weight: 400\">hint, will instruct the query service to consider using FTS index instead. Note that the index name `all_acts` is optional.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT * FROM crm a\r\nWHERE a.type='activity' USE INDEX (USING FTS) \r\n \/* 1  *\/ AND a.title LIKE 'Announcing Couchbase Flex Index%'\r\n \/* 2  *\/ AND a.dept = 'st55'\r\n \/* 3  *\/ AND a.region = '00528'\r\n \/* 4  *\/ AND a.priority = 'High'\r\n \/* 5  *\/ AND a.act_date BETWEEN '2020-08-01' AND '2020-08-31'\r\n \/* 6  *\/ AND a.event.location = 'Moscone Center' \r\n \/* 7  *\/ AND a.event.name = 'N1QL Flex Index vs ElasticSQL'\r\n \/* 8  *\/ AND a.event.vendor = 'Kempinski'\r\n \/* 9  *\/ AND a.event.theme = 'CouchbaseRed'\r\n \/* 10 *\/ AND a.account.id = 'acc134'\r\n \/* 11 *\/ AND a.account.name = 'Horizon Cellular'\r\n \/* 12 *\/ AND a.owner.id = 'usr24'\r\n \/* 13 *\/ AND a.owner.name = 'John Higgins'\r\n<\/pre>\n<h5><span style=\"font-weight: 400\">Query Plan:<\/span><\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9033\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.39.31-PM.png\" alt=\"\" width=\"785\" height=\"70\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.39.31-PM.png 1009w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.39.31-PM-300x27.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.39.31-PM-768x69.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.39.31-PM-20x2.png 20w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/p>\n<h5>Query Execution:<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9034\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM.png\" alt=\"\" width=\"821\" height=\"50\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM.png 1608w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM-300x18.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM-1024x62.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM-768x47.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM-1536x94.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM-20x1.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-1.52.53-PM-1320x80.png 1320w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/p>\n<p><b>Key point to note<\/b><span style=\"font-weight: 400\">: The query can have any varying number of predicates, and in any field combinations, and the query should still consider the FTS index.<\/span><\/p>\n<h3><span style=\"font-weight: 400\">3) Flex Index Query with combinations of\u00a0 logical operators &#8211; AND\/OR<\/span><\/h3>\n<p><span style=\"font-weight: 400\">The benefit of the FTS index with regard to predicate combinations also extends further with the way each of the index fields is created. Because each indexed field has its own inverted structure, and because the Bleve routine creates a bitmap for each search condition,\u00a0 predicate combinations such as AND\/OR\/NOT are processed much more efficiently compared to the intersect-scan with B-Tree index.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The example below shows that even though there are several logical operators OR in the query, the `all_acts` FTS index is still be considered.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT * FROM crm a USE INDEX (USING FTS)\r\nWHERE a.type='activity'\r\nAND ( a.dept = 'iA88'\r\n    OR a.region &gt; '59416' )\r\nAND a.priority = 'High'\r\nAND ( a.act_date BETWEEN '2018-01-01' AND '2018-08-31'\r\n    OR a.event.location = 'Moscone Center' )\r\nAND ( a.account.id = 'acc100'\r\n     OR a.owner.name = 'Amanda Morrison')\r\nLIMIT 10<\/pre>\n<h5>Query Plan:<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9036\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM.png\" alt=\"\" width=\"703\" height=\"55\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM.png 2124w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-300x23.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-1024x80.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-768x60.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-1536x120.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-2048x160.png 2048w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-20x2.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.04.34-PM-1320x103.png 1320w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/p>\n<h5><span style=\"font-weight: 400\">Query Execution:<\/span><\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9035\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM.png\" alt=\"\" width=\"733\" height=\"44\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM.png 1672w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM-300x18.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM-1024x61.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM-768x46.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM-1536x92.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM-20x1.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.02.56-PM-1320x79.png 1320w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<h3><span style=\"font-weight: 400\">4) Query involves multiple array predicates\u00a0<\/span><\/h3>\n<p><span style=\"font-weight: 400\">The versatility of the FTS index does not just stop with its ability to use the index with only a subset of the indexed fields in the search condition, or its ability to efficiently combine the search results with logical operators. But also the way FTS index handles array elements\u00a0 which allows the N1QL query to have any number of the array predicates.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Now let&#8217;s extend the query further with array predicates:<\/span><\/p>\n<pre class=\"lang:mysql decode:true \">SELECT * FROM crm a\r\nWHERE a.type='activity' USE INDEX (USING FTS) \r\n \/* 1  *\/ AND a.title LIKE 'Announcing Couchbase Flex Index%'\r\n \/* 2  *\/ AND a.dept = 'st55'\r\n \/* 3  *\/ AND a.region = '00528'\r\n \/* 4  *\/ AND a.priority = 'High'\r\n \/* 5  *\/ AND a.act_date BETWEEN '2020-08-01' AND '2020-08-31'\r\n \/* 6  *\/ AND a.event.location = 'Moscone Center South' \r\n \/* 7  *\/ AND a.event.name = 'N1QL Flex Index vs ElasticSQL'\r\n \/* 8  *\/ AND a.event.vendor = 'Kempskinki'\r\n \/* 9  *\/ AND a.event.theme = 'CouchbaseRed'\r\n \/* 10 *\/ AND a.account.id = 'acc134'\r\n \/* 11 *\/ AND a.account.name = 'Horizon Cellular'\r\n \/* 12 *\/ AND a.owner.id = 'usr24'\r\n \/* 13 *\/ AND a.owner.name = 'Binh Le'\r\n\r\n \/* 14 *\/ AND ANY pa IN a.participants SATISFIES pa.name LIKE 'Randy%' END\r\n \/* 15 *\/ AND ANY co IN a.appointment.contacts SATISFIES co.title LIKE 'System Arch%' END<\/pre>\n<p>You do need to add the two arrays to the the index as child mappings as below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9037\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-2.09.29-PM.png\" alt=\"\" width=\"625\" height=\"347\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.09.29-PM.png 1060w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.09.29-PM-300x166.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.09.29-PM-1024x568.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.09.29-PM-768x426.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.09.29-PM-20x11.png 20w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<h3><span style=\"font-weight: 400\">5) The difference search syntax<\/span><\/h3>\n<p><span style=\"font-weight: 400\">This is a use case, where you are using FTS primarily with keyword search, and prefer a simpler SQL like search predicate syntax.<br \/>\n<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9041\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-2.46.07-PM.png\" alt=\"\" width=\"637\" height=\"279\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.46.07-PM.png 637w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.46.07-PM-300x131.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.46.07-PM-20x9.png 20w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/p>\n<h2><span style=\"font-weight: 400\">N1QL and Search without limitations<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The modern enterprise applications require both exact search and text search. For exact search most RDBMS provide B-Tree based index to meet the needs. The requirements for text search have increased the popularity of the Lucene based search engines, such as ElasticSearch and Solr.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Oracle NoSQL now has integration with ElasticSearch: <\/span><a href=\"https:\/\/docs.oracle.com\/en\/database\/other-databases\/nosql-database\/18.1\/full-text-search\/index.html#NSFTL-GUID-E409CC44-9A8F-4043-82C8-6B95CD939296\">https:\/\/docs.oracle.com\/en\/database\/other-databases\/nosql-database\/18.1\/full-text-search\/index.html#NSFTL-GUID-E409CC44-9A8F-4043-82C8-6B95CD939296<\/a><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Oracle Enterprise RDBMS based applications also provide ElasticSearch capability as an option using the CX application suite. <a href=\"https:\/\/www.oracle.com\/webfolder\/technetwork\/tutorials\/tutorial\/cloud\/r13\/wn\/engagement\/releases\/20B\/20B-engagement-wn.htm\">https:\/\/www.oracle.com\/webfolder\/technetwork\/tutorials\/tutorial\/cloud\/r13\/wn\/engagement\/releases\/20B\/20B-engagement-wn.htm<\/a><\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">But adopting ElasticSearch functionality in a highly normalized RDBMS data model brings a number of challenges.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The resource requirements to set up ElasticSearch, as well as the storage requirements to ingest the RDBMS data for the ElasticSearch database.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The need to denormalize the data model extensively, as Lucene based search does not support database JOIN.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The development effort to implement the search using ElasticSearch APIs.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">The\u00a0 effort for customers who want to use ElasticSearch is one of the key reasons why we have seen the adoption of SQL in these NoSQL databases.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Elasticsearch with SQL. <a href=\"https:\/\/www.elastic.co\/what-is\/elasticsearch-sql\">https:\/\/www.elastic.co\/what-is\/elasticsearch-sql<\/a><\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Opendistro for Elasticsearch with SQL. <a href=\"https:\/\/opendistro.github.io\/for-elasticsearch\/features\/SQL%20Support.html\">https:\/\/opendistro.github.io\/for-elasticsearch\/features\/SQL%20Support.html<\/a><\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">MongoDB has added search to MQL using Lucene in its Atlas offering. <a href=\"https:\/\/www.mongodb.com\/atlas\/search\">https:\/\/www.mongodb.com\/atlas\/search<\/a><\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">But the SQL Implementations of these databases come with a long list of limitations.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">ElasticSQL limitations: <\/span><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/sql-limitations.html\"><span style=\"font-weight: 400\">https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/sql-limitations.html<\/span><\/a>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">No support for set operations joins, etc, etc.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">No window functions.<\/span><\/li>\n<\/ol>\n<\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">MongoDB\u2019s MQL\u2019s search integration comes with a long list of limitations.<\/span>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Available only on the Atlas search service, not on the on-premise product.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Search can only be the FIRST operation within the aggregate() pipeline.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Available only within the aggregation pipeline (aggregate()), which means it can&#8217;t be used with updates or deletes as predicate.<\/span><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Couchbase, on the other hand, has had N1QL and Full Text Search for many years. The query language supports all the operations that you would expect to see in a mature database, supporting RDBMS-like joins, aggregations, both rule-based and cost-based query optimization.\u00a0 Most important are the additional constructs such as NEST, UNNEST, and ARRAY operations to allow the N1QL language to work natively with JSON documents.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The important point about Couchbase N1QL with regard to search capabilities is that Couchbase Full Text Search is seamlessly integrated into its N1QL language.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Couchbase 6.5 N1QL Search function. <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/searchfun.html\">https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/searchfun.html<\/a><\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Couchbase 6.6 Flex Index (the topic of this article). <a href=\"https:\/\/docs.couchbase.com\/server\/6.6\/n1ql\/n1ql-language-reference\/flex-indexes.html\">https:\/\/docs.couchbase.com\/server\/6.6\/n1ql\/n1ql-language-reference\/flex-indexes.html<\/a><\/span><\/li>\n<\/ol>\n<h3><span style=\"font-weight: 400\">Flex Index with the power of N1QL<\/span><\/h3>\n<p>Here is an example N1QL query for a requirement to analyze\u00a0 i) how much time the sales team has spent working with all the customer by <code>industry<\/code>, and also ii) returns the top three <code>skillsets<\/code> from the sales team members who have worked with these customers.<\/p>\n<p><span style=\"font-weight: 400\">The query shows that Couchbase Flex Index can be used with the combination of any N1QL features.\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9038 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-03-at-2.13.18-PM.png\" alt=\"Full Text Search Index\" width=\"1099\" height=\"660\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.13.18-PM.png 1099w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.13.18-PM-300x180.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.13.18-PM-1024x615.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.13.18-PM-768x461.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/Screen-Shot-2020-08-03-at-2.13.18-PM-20x12.png 20w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-weight: 400\">Flex Index Considerations<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The discussion so far has illustrated with examples how the Flex index feature can leverage a single multiple-field FTS index to meet all different types of predicate combinations and queries with multiple arrays, where with GSI you would need to have several indexes.\u00a0 But what would be the index size impact of using an FTS index instead of GSI? The table below shows what the index sizes are in my local Couchbase setup.<\/span><\/p>\n<h3>Index Size<\/h3>\n<p>The table below an example of index size based on the crm activity model dataset.<\/p>\n<p><span style=\"font-weight: 400\">Document size: <\/span> <span style=\"font-weight: 400\">1.5K.\u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400\">Document count: <\/span> <span style=\"font-weight: 400\">500K<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Index options<\/b><\/td>\n<td><b>GSI Index Size<\/b><\/td>\n<td><b>FTS Index Size<\/b><\/td>\n<td><b>Storage Difference<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Index on 13 fields<\/span><\/td>\n<td><span style=\"font-weight: 400\">205 MB<\/span><\/td>\n<td><span style=\"font-weight: 400\">252 MB<\/span><\/td>\n<td><span style=\"font-weight: 400\">+25%<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">13 fields +<\/span><b> all<\/b><span style=\"font-weight: 400\"> elements from both arrays<\/span><\/td>\n<td><span style=\"font-weight: 400\">N\/A<\/span><\/td>\n<td><span style=\"font-weight: 400\">357 MB<\/span><\/td>\n<td><span style=\"font-weight: 400\">&#8211;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\">The purpose of the above table is not meant to provide an accurate size of the two types of indexes, but rather the relative size differences between them.\u00a0<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The FTS index is around 25% greater in size compared to the GSI index. This number reflects the sample data, and the distribution of the indexed fields.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">There are a lot of savings when array elements are involved.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The FTS index can include all elements of both arrays in a single index.<\/span><\/li>\n<\/ol>\n<h3>Query Performance<\/h3>\n<p>Both Couchbase Indexing and the <a href=\"https:\/\/www.couchbase.com\/blog\/full-text-search-indexing-best-practices-by-use-case\/\">Full-Text Search indexing<\/a> services have been designed to scale with Multi Dimensional Scaling, and High Availability. That said, these services are designed to meet different goals. Indexing service works best for high latency and high throughput requirements. The search conditions for these queries are expected to be well defined with small result sets. FTS service, on the other hand, was designed with advanced analyzer support to add an element of fuzziness, language aware, as well as providing a relevancy score for each result.<\/p>\n<ol>\n<li>Queries which are based in Flex Index will always include a <code>fetch<\/code> phase in the query processing. This is because the query service will still be performing the <code>filter<\/code> phase.<\/li>\n<li>Query performance optimization, such as aggregation push-down to index is available only with GSI, and not with Flex Index.<\/li>\n<li>Covered index queries are available with GSI only.<\/li>\n<li>With Flex Index, query pagination is performed at the query level, as pagination cannot be pushed down to FTS.<\/li>\n<li>For JOIN queries, only the fields that\u00a0 can be used in an FTS search query will be passed to Flex Index.<\/li>\n<\/ol>\n<h2><span style=\"font-weight: 400\">Summary<\/span><\/h2>\n<p><span style=\"font-weight: 400\">While many NoSQL databases are trying to improve their query languages, either by mimicking SQL indirectly with MQL, or directly with SQL in ElasticSQL, to provide the ability to perform exact match search as well as text search. Only Couchbase N1QL Flex Index provides both of these types of search seamlessly with N1QL SEARCH(), and now with standard predicates available in N1QL Flex Index. Your SQL knowledge is all that you need to develop an application to leverage both types of search. Furthermore, the text search can also be combined with all the N1QL features, JOIN\/Aggregation\/CTE and advanced Analytical Window Functions, and NEST\/UNNEST\/ARRAY for your JSON documents.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">References<\/span><\/h2>\n<ol>\n<li><span style=\"font-weight: 400\">The Activity Management Data Model sample dataset used\u00a0 in this article. <a href=\"https:\/\/couchbase-sample-datasets.s3.us-east-2.amazonaws.com\/crm.tar\">https:\/\/couchbase-sample-datasets.s3.us-east-2.amazonaws.com\/crm.tar<\/a><\/span><\/li>\n<\/ol>\n<p><strong>Explore Couchbase Server 6.6 resources<\/strong><\/p>\n<p>&nbsp;<\/p>\n<table width=\"624\">\n<tbody>\n<tr>\n<td><strong>Blogs<\/strong><\/td>\n<td><strong>Docs and Tutorials<\/strong><\/td>\n<td><strong>Webpages and Webinars<\/strong><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/whats-new-and-improved-in-couchbase-server-6-6\/\">What\u2019s New in Couchbase Server 6.6<\/a><\/td>\n<td><a href=\"https:\/\/docs.couchbase.com\/server\/current\/introduction\/whats-new.html\">What\u2019s New in Couchbase Server 6.6?<\/a><\/td>\n<td><a href=\"https:\/\/event.on24.com\/eventRegistration\/EventLobbyServlet?target=reg20.jsp&amp;partnerref=website&amp;eventid=2566405&amp;sessionid=1&amp;key=9DB74CF2A4251458E10D64B86B68C0EF&amp;regTag=&amp;sourcepage=register\">New Features in Couchbase Server 6.6: Analytics, Backup, Query, and More<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/eventing-improvements-timers-handlers-and-statistics\/\">Eventing Improvements (Timers, Handlers, and Statistics)<\/a><\/td>\n<td><a href=\"https:\/\/docs.couchbase.com\/server\/6.6\/release-notes\/relnotes.html\">Couchbase Server 6.6 Release Notes<\/a><\/td>\n<td><a href=\"https:\/\/www.couchbase.com\/products\/analytics\/\">Couchbase Analytics Service<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/remote-links-analyze-your-enterprise-with-couchbase-analytics\/\">Remote Links \u2013 Analyze Your Enterprise With Couchbase Analytics<\/a><\/td>\n<td><a href=\"https:\/\/index-advisor.couchbase.com\/indexadvisor\/#1\">Try the Couchbase Index Advisor Service<\/a><\/td>\n<td><a href=\"https:\/\/www.couchbase.com\/products\/server\/whats-new\/\">What\u2019s New in Couchbase Server (Product Page)<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/external-datasets-extend-your-reach-with-couchbase-analytics\/\">External Datasets \u2013 Extend Your Reach With Couchbase Analytics<\/a><\/td>\n<td><a href=\"https:\/\/docs.couchbase.com\/server\/current\/analytics\/rest-links.html\">Set Up Analytics Remote and S3 Links Using REST API<\/a><\/td>\n<td><a href=\"https:\/\/www.couchbase.com\/products\/editions\/\">Compare Editions<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/\">Announcing Flex Index With Couchbase<\/a><\/td>\n<td><a href=\"https:\/\/docs.couchbase.com\/server\/current\/analytics\/5_ddl.html\">Create External Datasets Using Data Definition Language (DDL)<\/a><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/introducing-backing-up-to-object-store-s3\/\">Introducing Backing Up to Object Store (S3)<\/a><\/td>\n<td><a href=\"https:\/\/docs.couchbase.com\/server\/current\/cli\/cbcli\/couchbase-cli-analytics-link-setup.html\">Set Up Analytics Remote and S3 Links Using CLI<\/a><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.couchbase.com\/blog\/import-documents-with-admin-ui\/\">Import Documents With the Web Admin Console<\/a><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flex Index Explained What is a Flex Index? One of the key tasks of a database engine is how to efficiently manage the search and retrieval of the data therein. The efficiency and balance between resource consumption and performance are [&hellip;]<\/p>\n","protected":false},"author":26326,"featured_media":9153,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1814,2165,1812],"tags":[1725],"ppma_author":[8919],"class_list":["post-9025","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-design","category-full-text-search","category-n1ql-query","tag-nosql-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Announcing Flex Index With Couchbase - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"The Flex Index is a unique Couchbase innovation that uses the inverted indexes from Full-Text Search in complex Couchbase N1QL queries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Announcing Flex Index With Couchbase\" \/>\n<meta property=\"og:description\" content=\"The Flex Index is a unique Couchbase innovation that uses the inverted indexes from Full-Text Search in complex Couchbase N1QL queries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-12T16:00:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:27:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/indexing.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1400\" \/>\n\t<meta property=\"og:image:height\" content=\"553\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Binh Le\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Binh Le\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/\"},\"author\":{\"name\":\"Binh Le\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/f89064928e262c71eb43bee996c48c63\"},\"headline\":\"Announcing Flex Index With Couchbase\",\"datePublished\":\"2020-08-12T16:00:13+00:00\",\"dateModified\":\"2025-06-14T03:27:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/\"},\"wordCount\":3186,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2020\\\/08\\\/indexing.jpg\",\"keywords\":[\"NoSQL Database\"],\"articleSection\":[\"Application Design\",\"Full-Text Search\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/\",\"name\":\"Announcing Flex Index With Couchbase - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2020\\\/08\\\/indexing.jpg\",\"datePublished\":\"2020-08-12T16:00:13+00:00\",\"dateModified\":\"2025-06-14T03:27:37+00:00\",\"description\":\"The Flex Index is a unique Couchbase innovation that uses the inverted indexes from Full-Text Search in complex Couchbase N1QL queries.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2020\\\/08\\\/indexing.jpg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2020\\\/08\\\/indexing.jpg\",\"width\":1400,\"height\":553,\"caption\":\"Flex Index is Amazing\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/announcing-flex-index-with-couchbase\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Announcing Flex Index With Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/f89064928e262c71eb43bee996c48c63\",\"name\":\"Binh Le\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g5b68c37e30928a9d7b2c8470b1a303b7\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g\",\"caption\":\"Binh Le\"},\"description\":\"Binh Le is a Principal Product Manager for Couchbase Query service. Prior to Couchbase, he worked at Oracle and led the product management team for Sales Cloud Analytics and CRM OnDemand. Binh holds a Bachelor's Degree in Computer Science from the University of Brighton, UK.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/binh-le-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Announcing Flex Index With Couchbase - The Couchbase Blog","description":"The Flex Index is a unique Couchbase innovation that uses the inverted indexes from Full-Text Search in complex Couchbase N1QL queries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/","og_locale":"en_US","og_type":"article","og_title":"Announcing Flex Index With Couchbase","og_description":"The Flex Index is a unique Couchbase innovation that uses the inverted indexes from Full-Text Search in complex Couchbase N1QL queries.","og_url":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2020-08-12T16:00:13+00:00","article_modified_time":"2025-06-14T03:27:37+00:00","og_image":[{"width":1400,"height":553,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/indexing.jpg","type":"image\/jpeg"}],"author":"Binh Le","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Binh Le","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/"},"author":{"name":"Binh Le","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/f89064928e262c71eb43bee996c48c63"},"headline":"Announcing Flex Index With Couchbase","datePublished":"2020-08-12T16:00:13+00:00","dateModified":"2025-06-14T03:27:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/"},"wordCount":3186,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/indexing.jpg","keywords":["NoSQL Database"],"articleSection":["Application Design","Full-Text Search","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/","name":"Announcing Flex Index With Couchbase - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/indexing.jpg","datePublished":"2020-08-12T16:00:13+00:00","dateModified":"2025-06-14T03:27:37+00:00","description":"The Flex Index is a unique Couchbase innovation that uses the inverted indexes from Full-Text Search in complex Couchbase N1QL queries.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/indexing.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/08\/indexing.jpg","width":1400,"height":553,"caption":"Flex Index is Amazing"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/announcing-flex-index-with-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Announcing Flex Index With Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/f89064928e262c71eb43bee996c48c63","name":"Binh Le","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g5b68c37e30928a9d7b2c8470b1a303b7","url":"https:\/\/secure.gravatar.com\/avatar\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g","caption":"Binh Le"},"description":"Binh Le is a Principal Product Manager for Couchbase Query service. Prior to Couchbase, he worked at Oracle and led the product management team for Sales Cloud Analytics and CRM OnDemand. Binh holds a Bachelor's Degree in Computer Science from the University of Brighton, UK.","url":"https:\/\/www.couchbase.com\/blog\/author\/binh-le-2\/"}]}},"acf":[],"authors":[{"term_id":8919,"user_id":26326,"is_guest":0,"slug":"binh-le-2","display_name":"Binh Le","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/a939f48df6447844a8780bec264bb3be21d589336f3915fabc557075a68fa374?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/9025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/26326"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=9025"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/9025\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/9153"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=9025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=9025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=9025"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=9025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}