{"id":11930,"date":"2021-09-20T00:00:19","date_gmt":"2021-09-20T07:00:19","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=11930"},"modified":"2025-06-13T21:22:55","modified_gmt":"2025-06-14T04:22:55","slug":"how-to-full-text-search-javascript-app","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/","title":{"rendered":"How to Add Full-Text Search Functionality to Your JavaScript App"},"content":{"rendered":"<p><strong>It&#8217;s unavoidable:<\/strong> If you&#8217;re working with a document database, you&#8217;re eventually going to need to search for (and through) your JSON documents.<\/p>\n<p>In this tutorial, you&#8217;ll add the full-text search capabilities of Couchbase to the basic REST API built with Express that we&#8217;ve been building throughout this Node.js series.<\/p>\n<p>The previous post in this series <a href=\"https:\/\/www.couchbase.com\/blog\/how-to-query-json-data-n1ql-node-js-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">used Express to build a basic API for creating N1QL queries<\/a>.<\/p>\n<p>Today&#8217;s post takes you a step further. You&#8217;ll learn how to find JSON documents that contain the text you&#8217;re after by adding functionality to your app that uses the <a href=\"https:\/\/www.couchbase.com\/products\/capella\/\" target=\"_blank\" rel=\"noopener\">Couchbase<\/a> Search API. Let&#8217;s get started.<\/p>\n<h2>What Is Full-Text Search?<\/h2>\n<p>Full-text search (FTS) is a strange name, but it&#8217;s a well-developed concept in academic areas focused on analyzing large pieces of text content. In the database domain we just call it &#8220;search&#8221; for shorthand, and it&#8217;s focused on finding text within JSON documents.<\/p>\n<p>Application developers use search-related tools to find matches without having to write SQL queries which usually require you to know how\/where to find the data of interest. In a full-text search scenario you hunt for text with more sophistication.<\/p>\n<p>For example, search systems understand root-words using a concept known as stemming, so you don&#8217;t have to look for many permutations of a term manually. Likewise, wildcards, prefixes, and <a href=\"https:\/\/www.couchbase.com\/blog\/fuzzy-matching\/?ref=blog\" target=\"_blank\" rel=\"noopener\">fuzzy matching<\/a> are possible with robust search systems.<\/p>\n<h2>Setting Up Search Indexes<\/h2>\n<p>There are two steps to using a Search system: (1) indexing\/analyzing the text in each document and (2) requesting a list of documents that contain text-based matches.<\/p>\n<p><em>The indexing stage<\/em> is similar to creating secondary indexes for relational\/tabular data where you describe the fields or elements to be indexed and the system keeps track of them for you. You can also just tell the system to index every text field in the document, though for large datasets this may not be efficient in production.<\/p>\n<p><em>The querying stage<\/em> (a.k.a., the search) sends a piece of text to the server for it to hunt for. The system compares that text to the indexes and returns a list of documents with matches.<\/p>\n<p>Full-text search is straightforward, but there&#8217;s an infinite set of options and questions to consider, like:<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>How to handle phrases and numbers<\/li>\n<li>Identifying where in a document particular text exists<\/li>\n<li>Analyzing text across multiple languages<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Really, this is a deep-dive topic all of its own. The simple patterns used in this post can be expanded to all different search scenarios as described in <a href=\"https:\/\/docs.couchbase.com\/server\/current\/fts\/fts-introduction.html?ref=blog\" target=\"_blank\" rel=\"noopener\">this introduction to full-text search<\/a>.<\/p>\n<h2>Preparing Your Couchbase Instance<\/h2>\n<p>If you are new to this series of JavaScript coding tutorials, you need to install the `travel-sample` data Bucket, as described in the <a href=\"https:\/\/developer.couchbase.com\/new-to-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase documentation<\/a>.<\/p>\n<p>The script used in the previous post of this series is also going to be used as a starting point for today&#8217;s post. The Node.js code is included at <a href=\"https:\/\/www.couchbase.com\/blog\/how-to-query-json-data-n1ql-node-js-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">the end of that post<\/a>.<\/p>\n<p>As you progress through these Node.js tutorials you are building a more complex and useful REST API application. Let&#8217;s dive into creating the search index needed to support the next step of your project.<\/p>\n<h2>Build a Basic Text Search Index<\/h2>\n<p>To create a search index, you select the `Search` tab in the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-ui\/manage-ui.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Web Console<\/a> and press the `Add Index` button.<\/p>\n<p>Then enter the name you want to give the index and choose which Bucket to analyze (`travel-sample`). Finish by pressing the `Create Index` button to submit your choices. There are many different options to choose from, but in today&#8217;s example, we keep all the defaults for simplicity sake. The following animation shows each of these steps:<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/09\/create-full-text-search-index-in-couchbase.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11931\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/09\/create-full-text-search-index-in-couchbase-1024x576.gif\" alt=\"Process to create a search index using Couchbase Web Console\" width=\"900\" height=\"506\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/create-full-text-search-index-in-couchbase-1024x576.gif 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/create-full-text-search-index-in-couchbase-300x169.gif 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/create-full-text-search-index-in-couchbase-768x432.gif 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/create-full-text-search-index-in-couchbase-20x11.gif 20w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>After completing these steps, you should see your search indexes and their status in the Web Console. You should also be able to see how many documents were processed.<\/p>\n<p>Indexing on the `travel-sample` data Bucket takes a few minutes, but once it&#8217;s complete, you can do a sample search request through the basic web user interface as shown below.<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/09\/test-query-full-text-search-index-in-couchbase.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11932\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/09\/test-query-full-text-search-index-in-couchbase.gif\" alt=\"Entering a full-text search query on an index in the Couchbase Web Console\" width=\"540\" height=\"304\" \/><\/a><\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>You enter a simple term in the search box and a list of matching document IDs is returned with the highest-ranking matches at the top. The Web Console makes it easy to click on these IDs to see the full document text.<\/p>\n<h2>Creating a Simple Text Search Function<\/h2>\n<p>There are many additional options for fine-tuning your searches with boolean operations, fuzzy matching, and more. The Web Console only does a simple `query string` search and this is the same type you will implement in your code.<\/p>\n<p>To create the new full-text search function you need to:<\/p>\n<ol>\n<li>Provide a string to search for (e.g., &#8220;grand&#8221;).<\/li>\n<li>Specify the search index to use: `travelsearch`.<\/li>\n<li>Declare the query type to use: `queryString`.<\/li>\n<li>Assemble all the parts together and send to server.<\/li>\n<li>Receive results and display to user\/application.<\/li>\n<\/ol>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>These five lines of JavaScript code below are an example of setting these variables, bundling them together, passing to the cluster and printing the results to the console:<\/p>\n<pre class=\"toolbar:1 nums-toggle:false wrap-toggle:false show-plain:1 lang:js decode:true \">    const querystr = \"grand\";\r\n    const searchIndex = 'travelsearch';\r\n    const stringQuery = couchbase.SearchQuery.queryString(querystr);\r\n    const searchResult = cluster.searchQuery(searchIndex, stringQuery);\r\n    console.log(searchResult);\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>If you want to adjust the type of search query, swap out `queryString` on the third line with another method. Code samples of different types are provided in the <a href=\"https:\/\/docs.couchbase.com\/nodejs-sdk\/current\/howtos\/full-text-searching-with-sdk.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Full-Text Search documentation<\/a>.<\/p>\n<p>For example, a date range query looks like this:<br \/>\n<code><br \/>\nconst dateQuery = couchbase.SearchQuery.dateRange().start(startDate).end(endDate)<br \/>\n<\/code><\/p>\n<p>Here below is a full sample standalone script that includes the basic logic. We build it into the Express REST API example in the next section.<\/p>\n<pre class=\"toolbar:1 nums-toggle:false wrap-toggle:false show-plain:1 lang:js decode:true \">var couchbase = require(\"couchbase\");\r\n\r\nasync function main(){\r\n\r\nvar cluster = new couchbase.Cluster(\"couchbase:\/\/localhost\", {\r\n  username: \"Administrator\",\r\n  password: \"Administrator\"\r\n});\r\n\r\nvar bucket = cluster.bucket(\"travel-sample\");\r\nvar collection = bucket.defaultCollection();\r\n\r\n    const querystr = \"grand\";\r\n    const searchIndex = 'travelsearch';\r\n    const stringQuery = couchbase.SearchQuery.queryString(querystr);\r\n    const searchResult = await cluster.searchQuery(searchIndex, stringQuery);\r\n    console.log(searchResult);\r\n\r\n    if (searchResult.meta.status.failed == 0) {\r\n        searchResult.rows.forEach((row)=&gt;{\r\n          console.log(row);\r\n        });\r\n      }\r\n}\r\n\r\nmain();\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>Taking the Code Further<\/h2>\n<p>Continuing our example, you can now add it to the REST API code we built in <a href=\"https:\/\/www.couchbase.com\/blog\/how-to-query-json-data-n1ql-node-js-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">last week&#8217;s tutorial<\/a>.<\/p>\n<p>Add the code along with the new Express routing so you can send a search request from a URL in the browser. In this case, the path will be: `\/search\/[search term]` \u2013 e.g., `\/search\/grand`.<\/p>\n<p>Here is the route definition for building the full-text search query:<\/p>\n<pre class=\"toolbar:1 nums-toggle:false wrap-toggle:false show-plain:1 lang:js decode:true \">  app.get('\/search\/:searchterm',\r\n    runAsync(async (req, res) =&gt; {\r\n      const querystr = req.params.searchterm;\r\n      const searchIndex = 'travelsearch';\r\n      const stringQuery = couchbase.SearchQuery.queryString(querystr);\r\n\r\n      const searchResult = await cluster.searchQuery(\r\n        searchIndex,\r\n        stringQuery,\r\n        \/\/ add options in their own object:\r\n        { timeout:2000, limit:5}\r\n        ).catch((e)=&gt;{console.log(e); throw e;});\r\n\r\n      if (searchResult.meta.status.failed == 0) {\r\n        res.json(searchResult);\r\n        searchResult.rows.forEach((row)=&gt;{\r\n          console.log(row);\r\n        })\r\n      }\r\n  }))\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Click below for the full working REST API code, including the document fetch, N1QL query, and search routes:<\/p>\n<pre class=\"toolbar:1 nums-toggle:false wrap-toggle:false show-plain:1 minimize:true lang:js decode:true \">var app = require('express')();\r\n\r\nvar couchbase = require(\"couchbase\");\r\n\r\nasync function main() {\r\n\r\n  app.get('\/get\/:docid',\r\n    runAsync(async (req, res) =&gt; {\r\n      var docid = req.params.docid;\r\n      var docjson = await getDoc(docid, function(err, result){\r\n        res.json(result.content)\r\n      });\r\n\r\n      res.json(docjson.content);\r\n  }));\r\n\r\n  app.get('\/query\/:cityname',\r\n    runAsync(async (req, res) =&gt; {\r\n      var cityname = req.params.cityname;\r\n\r\n      var querystr = `SELECT type, name, city FROM \\`travel-sample\\` WHERE city = $CITY;`\r\n      var params = { parameters: { CITY: cityname}}\r\n\r\n      await cluster.query(querystr, params, function(err, result){\r\n        res.json(result)\r\n      })\r\n  }));\r\n\r\n  app.get('\/search\/:searchterm',\r\n    runAsync(async (req, res) =&gt; {\r\n      const querystr = req.params.searchterm;\r\n      const searchIndex = 'travelsearch';\r\n      const stringQuery = couchbase.SearchQuery.queryString(querystr);\r\n\r\n      const searchResult = await cluster.searchQuery(\r\n        searchIndex,\r\n        stringQuery,\r\n        \/\/ add options in their own object:\r\n        {timeout:2000, limit:5}\r\n        ).catch((e)=&gt;{console.log(e); throw e;});\r\n\r\n      if (searchResult.meta.status.failed == 0) {\r\n        res.json(searchResult);\r\n        searchResult.rows.forEach((row)=&gt;{\r\n          console.log(row);\r\n        })\r\n      }\r\n  }))\r\n\r\n  app.listen(3000, () =&gt; console.log('Listening on port 3000'));\r\n\r\n  function runAsync (callback) {\r\n    return function (req, res, next) {\r\n      callback(req, res, next)\r\n      .catch(next)\r\n    }\r\n  }\r\n\r\n  var cluster = new couchbase.Cluster(\"couchbase:\/\/localhost\", {\r\n    username: \"Administrator\",\r\n    password: \"Administrator\"\r\n  });\r\n\r\n  var bucket = cluster.bucket(\"travel-sample\");\r\n  var collection = bucket.defaultCollection();\r\n\r\n  var getDoc = async (key) =&gt; {\r\n      var result = await collection.get(key);\r\n      console.log(result)\r\n      return result\r\n  }\r\n}\r\n\r\nmain();\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>Running the Search Query REST API<\/h2>\n<p>Access the application through the web browser on port 3000 and with the search path: `https:\/\/localhost:3000\/search\/grand`.<\/p>\n<p>The results of the search are shown here and include a list of matching document IDs and the ranking score of the match:<\/p>\n<pre class=\"toolbar:1 nums-toggle:false wrap-toggle:false show-plain:1 lang:js decode:true \">{\"rows\":[{\"index\":\"travelsearch_1bf0c4c01d25b582_4c1c5584\",\"id\":\"landmark_21813\",\"score\":1.063667683545401,\"sort\":[\"_score\"]},\r\n{\"index\":\"travelsearch_1bf0c4c01d25b582_4c1c5584\",\"id\":\"airport_7057\",\"score\":1.016530994468649,\"sort\":[\"_score\"]},\r\n{\"index\":\"travelsearch_1bf0c4c01d25b582_4c1c5584\",\"id\":\"airport_4063\",\"score\":1.0098211451111556,\"sort\":[\"_score\"]},\r\n{\"index\":\"travelsearch_1bf0c4c01d25b582_4c1c5584\",\"id\":\"airport_3442\",\"score\":1.0098211451111556,\"sort\":[\"_score\"]},\r\n{\"index\":\"travelsearch_1bf0c4c01d25b582_4c1c5584\",\"id\":\"airport_6448\",\"score\":1.0032424768865669,\"sort\":[\"_score\"]}],\r\n\"meta\":{\"status\":{\"total\":1,\"failed\":0,\"successful\":1},\"request\":{\"query\":{\"query\":\"grand\"},\"size\":5,\"from\":0,\"highlight\":null,\r\n\"fields\":null,\"facets\":null,\"explain\":false,\r\n\"sort\":[\"-_score\"],\"includeLocations\":false,\r\n\"search_after\":null,\"search_before\":null},\r\n\"hits\":[],\"total_hits\":169,\"max_score\":1.063667683545401,\"took\":208427,\"facets\":null}}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Note that the search results also include some useful metadata that shows the total number of hits\/matches, execution time and more.<\/p>\n<h2>Conclusion<\/h2>\n<p>The opportunities for using Couchbase in search-based applications are endless.<\/p>\n<p>With all the different types of queries and other search options available, there&#8217;s still a lot more to learn. Here are a few launching points for you to consider:<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>Read the docs and substitute for <a href=\"https:\/\/docs.couchbase.com\/server\/current\/fts\/fts-introduction.html?ref=blog\" target=\"_blank\" rel=\"noopener\">another type of search query<\/a>.<\/li>\n<li>Complete the <a href=\"https:\/\/learn.couchbase.com\/store?utf8=%E2%9C%93&amp;ss=1&amp;ct=82921&amp;commit=Filter&amp;ref=blog\" target=\"_blank\" rel=\"noopener\">Node.js &amp; Couchbase certification course.<\/a><\/li>\n<li>Take the <a href=\"https:\/\/learn.couchbase.com\/store\/1072989-cb131-couchbase-associate-architect-certification-course\/?ref=blog\" target=\"_blank\" rel=\"noopener\">free online Architect certification course<\/a> which covers full-text search and more<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>That&#8217;s a wrap for this series on developing with Node.js and Couchbase. Good luck on your continued journey with JavaScript!<\/p>\n<p><em>Catch up with the rest of the Node.js + Couchbase how-to series:<\/em><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/get-started-nodejs-sdk-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">How to Get Started with the Node.js SDK for Couchbase<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/how-to-create-nodejs-async-get-upsert-calls-with-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">How to Create Async Get\/Upsert Calls with Node.js and Couchbase<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/build-a-rest-api-with-node-js-express-and-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Build a REST-Based Application with Node.js, Express and Couchbase<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/how-to-query-json-data-n1ql-node-js-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">How to Query JSON Data Using N1QL for Node.js and Couchbase<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/?ref=blog\" target=\"_blank\" rel=\"noopener\">How to Add Full-Text Search Functionality to Your JavaScript App<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 30px\" aria-hidden=\"true\"><\/div>\n<div style=\"text-align: center\"><strong>It&#8217;s time to try it out for yourself:&lt;br\/ &gt;<a href=\"https:\/\/www.couchbase.com\/downloads\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Download Couchbase 7 today<\/a><\/strong><\/div>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s unavoidable: If you&#8217;re working with a document database, you&#8217;re eventually going to need to search for (and through) your JSON documents. In this tutorial, you&#8217;ll add the full-text search capabilities of Couchbase to the basic REST API built with [&hellip;]<\/p>\n","protected":false},"author":75185,"featured_media":11937,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1816,2165,9381,9327,1822,1812,7277,2201],"tags":[2312,1254,1543,1261,1950],"ppma_author":[9163],"class_list":["post-11930","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-server","category-full-text-search","category-indexing","category-javascript","category-node-js","category-n1ql-query","category-text-analysis","category-tools-sdks","tag-document-database","tag-express","tag-javascript","tag-json","tag-rest-api"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Full-Text Search Functionality: Adding to Your JavaScript App<\/title>\n<meta name=\"description\" content=\"Find out how to add full-text search functionality to your JavaScript App. This will allow you to find the JSON documents containing the text you need.\" \/>\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\/how-to-full-text-search-javascript-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Add Full-Text Search Functionality to Your JavaScript App\" \/>\n<meta property=\"og:description\" content=\"Find out how to add full-text search functionality to your JavaScript App. This will allow you to find the JSON documents containing the text you need.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-20T07:00:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:22:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app-social.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"418\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tyler Mitchell - Senior Product Marketing Manager\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app-social.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@1tylermitchell\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tyler Mitchell - Senior Product Marketing Manager\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/\"},\"author\":{\"name\":\"Tyler Mitchell - Senior Product Marketing Manager\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0\"},\"headline\":\"How to Add Full-Text Search Functionality to Your JavaScript App\",\"datePublished\":\"2021-09-20T07:00:19+00:00\",\"dateModified\":\"2025-06-14T04:22:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/\"},\"wordCount\":1258,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg\",\"keywords\":[\"document database\",\"express\",\"javascript\",\"JSON\",\"REST API\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Server\",\"Full-Text Search\",\"Indexing\",\"JavaScript\",\"Node.js\",\"SQL++ \/ N1QL Query\",\"Text Analysis\",\"Tools &amp; SDKs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/\",\"name\":\"Full-Text Search Functionality: Adding to Your JavaScript App\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg\",\"datePublished\":\"2021-09-20T07:00:19+00:00\",\"dateModified\":\"2025-06-14T04:22:55+00:00\",\"description\":\"Find out how to add full-text search functionality to your JavaScript App. This will allow you to find the JSON documents containing the text you need.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg\",\"width\":1200,\"height\":628,\"caption\":\"Learn how to use the Full-Text Search API in Couchbase to add search to your JavaScript application\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Add Full-Text Search Functionality to Your JavaScript App\"}]},{\"@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\/684cc0e5c60cd2e4b591db9621494ed0\",\"name\":\"Tyler Mitchell - Senior Product Marketing Manager\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/d8a7c532bf2b94b7a2fe7a8439aafd75\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g\",\"caption\":\"Tyler Mitchell - Senior Product Marketing Manager\"},\"description\":\"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind.\",\"sameAs\":[\"https:\/\/linkedin.com\/in\/tylermitchell\",\"https:\/\/x.com\/1tylermitchell\",\"https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Full-Text Search Functionality: Adding to Your JavaScript App","description":"Find out how to add full-text search functionality to your JavaScript App. This will allow you to find the JSON documents containing the text you need.","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\/how-to-full-text-search-javascript-app\/","og_locale":"en_US","og_type":"article","og_title":"How to Add Full-Text Search Functionality to Your JavaScript App","og_description":"Find out how to add full-text search functionality to your JavaScript App. This will allow you to find the JSON documents containing the text you need.","og_url":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-09-20T07:00:19+00:00","article_modified_time":"2025-06-14T04:22:55+00:00","og_image":[{"width":800,"height":418,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app-social.jpg","type":"image\/jpeg"}],"author":"Tyler Mitchell - Senior Product Marketing Manager","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app-social.jpg","twitter_creator":"@1tylermitchell","twitter_misc":{"Written by":"Tyler Mitchell - Senior Product Marketing Manager","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/"},"author":{"name":"Tyler Mitchell - Senior Product Marketing Manager","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0"},"headline":"How to Add Full-Text Search Functionality to Your JavaScript App","datePublished":"2021-09-20T07:00:19+00:00","dateModified":"2025-06-14T04:22:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/"},"wordCount":1258,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg","keywords":["document database","express","javascript","JSON","REST API"],"articleSection":["Best Practices and Tutorials","Couchbase Server","Full-Text Search","Indexing","JavaScript","Node.js","SQL++ \/ N1QL Query","Text Analysis","Tools &amp; SDKs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/","url":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/","name":"Full-Text Search Functionality: Adding to Your JavaScript App","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg","datePublished":"2021-09-20T07:00:19+00:00","dateModified":"2025-06-14T04:22:55+00:00","description":"Find out how to add full-text search functionality to your JavaScript App. This will allow you to find the JSON documents containing the text you need.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/09\/full-text-search-fts-functionality-javascript-nodejs-app.jpg","width":1200,"height":628,"caption":"Learn how to use the Full-Text Search API in Couchbase to add search to your JavaScript application"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/how-to-full-text-search-javascript-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Add Full-Text Search Functionality to Your JavaScript App"}]},{"@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\/684cc0e5c60cd2e4b591db9621494ed0","name":"Tyler Mitchell - Senior Product Marketing Manager","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/d8a7c532bf2b94b7a2fe7a8439aafd75","url":"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g","caption":"Tyler Mitchell - Senior Product Marketing Manager"},"description":"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind.","sameAs":["https:\/\/linkedin.com\/in\/tylermitchell","https:\/\/x.com\/1tylermitchell","https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg"],"url":"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/"}]}},"authors":[{"term_id":9163,"user_id":75185,"is_guest":0,"slug":"tylermitchell","display_name":"Tyler Mitchell - Senior Product Marketing Manager","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/876da1e4284f1832c871b3514caf7867357744b8c0a370ef6f53a79dee2f379e?s=96&d=mm&r=g","author_category":"","last_name":"Mitchell - Senior Product Marketing Manager","first_name":"Tyler","job_title":"Senior Product Marketing Manager","user_url":"","description":"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/11930","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\/75185"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=11930"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/11930\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/11937"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=11930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=11930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=11930"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=11930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}