---
title: Search
description: You can use the Search Service to create queryable Search indexes
  in Couchbase Server.
pubDate: 2026-08-17T09:53:44.266Z
antora:
  editUrl: https://github.com/couchbase/docs-sdk-nodejs/edit/temp/4.7/modules/howtos/pages/full-text-searching-with-sdk.adoc
  xref: xref:nodejs-sdk:howtos:full-text-searching-with-sdk.adoc[]
---

[Consult the llms.txt file for a full list of contents](/llms.txt)
[View original HTML](/nodejs-sdk/current/howtos/full-text-searching-with-sdk.html)

# Search

> You can use the Search Service to create queryable Search indexes in Couchbase Server. 

The Search Service allows you to create, manage, and query Search indexes on JSON documents stored in Couchbase buckets.

It uses natural language processing for querying documents, provides relevance scoring on the results of your queries, and has fast indexes for querying a wide range of possible text searches.

Supported query types include simple queries like Match and Term queries; range queries like Date Range and Numeric Range; and compound queries for conjunctions, disjunctions, and/or boolean queries.

The Node.js SDK exposes an API for performing Search queries which abstracts some of the complexity of using the underlying REST API.

The Search Service also supports vector search from Couchbase Server 7.6 onwards.

There are two APIs for querying search: `cluster.searchQuery()`, and `cluster.search()`. Both are also available at the Scope level.

The former API supports Search queries (`SearchQuery`), while the latter additionally supports the `VectorSearch` added in 7.6\. Most of this documentation will focus on the former API, as the latter is in `@Stability.Volatile` status.

## [](#examples)Examples

Search queries are executed at the cluster level (not bucket or collection). All examples below will console log our returned documents along with their metadata and rows, each returned document has an index, id, score and sort value.

Match

Using the `travel-sample` [Sample Bucket](../../../server/current/manage/manage-settings/install-sample-buckets.md), we define a Search Service SearchQuery using the `match()` method to search for the specified term: `"five-star"`.

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search.js[]
```

Match Phrase

A Search Service SearchQuery using the `matchPhrase()` method to find a specified phrase: `"10-minute walk from the"`.

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search.js[]
```

When searching for a phrase we get some additional benefits outside of the `match()` method. The match phrase query for `"10-minute walk from the"` will produce the following hits from our travel-sample dataset:

```bash
hits:
  hotel_11331: "10-minute walk from village"
  hotel_15915: "10 minute walk from Echo Arena"
  hotel_3606: "10 minute walk to the centre"
  hotel_28259: "10 minute walk to the coastal path"
```

If you run this code, notice that we matched `"10-minute"` with three additional hits on `"10 minute"` (without the dash). So, we get some of the same matches on variations of that term just as we would with a regular `match()` method search, however; notice that `"walk from the"` hits on several variations of this phrase: `"walk from"` (where `"the"` was removed) and `"walk to the"` (where `"from"` was removed). This is specific to searching phrases and helps provide us with various matches relevant to our search.

Date Range

Here we define a Search Service SearchQuery that uses the `dateRange()` method to search for hotels where the updated field (`datetime`) falls within a specified date range.

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search.js[]
```

Conjunction

A query satisfying multiple child queries. The example below will only return two documents hitting on the term `"five-star"` and the phrase `"luxury hotel"` while no other documents match both criteria.

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search-conjuncts-disjuncts.js[]
```

Note: Our match for `"five-star"` was not exact, but still produced a result because a similar term was found `"Five star"`, we could have potentially matched `"5 star"` or the word `"five"`. When you work with any Search query the number of hits you get and their score are variable.

Disjunction

A query satisfying (by default) one query or another. If a conjunction query can be thought of like using an `AND` operator, a disjunction would be like using an `OR` operator. The example below will return seven documents hitting on the term `"Louvre"` and five hits on the term `"Eiffel"` returning a total of 12 rows together as part of a disjunction query.

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search-conjuncts-disjuncts.js[]
```

> [!TIP]
> Search Results Limit
> 
> By default, the Search Service returns only the first 10 matches (`size: 10`, `from: 0`). To retrieve more results, you must explicitly define pagination settings such as `size` or `from` in your query.
> 
> For information about formatting your Search query and specifying limits, see [Search Request JSON Properties](../../../server/current/search/search-request-params.md).
> 
> For information about pagination in Search responses, see [Pagination](../../../server/current/fts/fts-search-response.md#pagination).

## [](#working-with-results)Working with Results

As with all query result types in the Node.js SDK, the search query results object contains two properties. The hits reflecting the documents that matched your query, emitted as rows. Along with the metadata available in the meta property.

Metadata holds additional information not directly related to your query, such as success total hits and how long the query took to execute in the cluster.

Iterating over Hits

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search-conjuncts-disjuncts.js[]
```

Facets

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search-conjuncts-disjuncts.js[]
```

## [](#scoped-vs-global-indexes)Scoped vs Global Indexes

The Search APIs exist at both the `Cluster` and `Scope` levels.

This is because the Search Service supports, as of Couchbase Server 7.6, a new form of "scoped index" in addition to the traditional "global index".

It's important to use the `Cluster.searchQuery()` / `Cluster.search()` for global indexes, and `Scope.search()` for scoped indexes.

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search.js[]
```

The `SearchQuery` is created in the same way as detailed earlier.

## [](#scan-consistency-and-consistentwith)Scan Consistency and ConsistentWith

By default, all Search queries will return the data from whatever is in the index at the time of query. These semantics can be tuned if needed so that the hits returned include the most recently performed mutations, at the cost of slightly higher latency since the index needs to be updated first.

There are two ways to control consistency: either by supplying a custom `SearchScanConsistency` or using `consistentWith`. At the moment the cluster only supports `consistentWith`, which is why you only see `SearchScanConsistency.NotBounded` in the enum which is the default setting. The way to make sure that recently written documents show up in the search works as follows (commonly referred to "read your own writes" — RYOW):

Scan consistency example:

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search.js[]
```

ConsistentWith Consistency Example:

```javascript
Unresolved include directive in modules/howtos/pages/full-text-searching-with-sdk.adoc - include::../examples/search.js[]
```