---
title: "Ends-With Query"
description: "Filter RavenDB documents where a field value ends with a specified string using the EndsWith query operator."
url: "https://docs.ravendb.net/7.2/client-api/session/querying/text-search/ends-with-query"
version: "7.2"
language: "nodejs"
---

# Ends-With Query

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/7.2/client-api/session/querying/text-search/ends-with-query.md), [Python](https://docs.ravendb.net/7.2/client-api/session/querying/text-search/ends-with-query.python.md), [PHP](https://docs.ravendb.net/7.2/client-api/session/querying/text-search/ends-with-query.php.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Use `whereEndsWith` to query for documents having a field that ends with some specified string.
>
> - Unless explicitly specified, the string comparisons are case-insensitive by default.
>
> - **Note**:  
>   This postfix search causes the server to perform a full index scan.  
>   Instead, consider using a static index that indexes the field in reverse order  
>   and then query with a [prefix search](https://docs.ravendb.net/7.2/client-api/session/querying/text-search/starts-with-query.nodejs.md), which is much faster.
>
> - In this page:
>   - [whereEndsWith](#whereendswith)
>   - [whereEndsWith (case-sensitive)](#whereendswith-\(case-sensitive\))
>   - [Negate whereEndsWith](#negate-whereendswith)
>   - [Syntax](#syntax)

## whereEndsWith

### Query

```javascript
const products = await session
  .query({ collection: "Products" })
   // Call 'whereEndsWith'
   // Pass the document field and the postfix to search by
  .whereEndsWith("Name", "Lager")
  .all();

// Results will contain only Product documents having a 'Name' field
// that ends with any case variation of 'lager'
```

### RQL

```sql
from "Products"
where endsWith(Name, "Lager")
```

## whereEndsWith (case-sensitive)

### Query

```javascript
const products = await session
  .query({ collection: "Products" })
  // Call 'whereEndsWith'
  // Pass 'true' as the 3'rd parameter to search for an EXACT postfix match
  .whereEndsWith("Name", "Lager", true)
  .all();

// Results will contain only Product documents having a 'Name' field
// that ends with 'Lager'
```

### RQL

```sql
from "Products"
where exact(endsWith(Name, "Lager"))
```

## Negate whereEndsWith

### Query

```javascript
const products = await session
  .query({ collection: "Products" })
  // Call 'Not' to negate the next predicate
  .not()
  // Call 'whereEndWith'
  // Pass the document field and the postfix to search by
  .whereEndsWith("Name", "Lager")
  .all();

// Results will contain only Product documents having a 'Name' field
// that does NOT end with 'lager' or any other case variations of it
```

### RQL

```sql
from "Products"
where exists(Name) and not endsWith(Name, "Lager")
```

## Syntax

```javascript
// Available overloads:
whereStartsWith(fieldName, value);
whereStartsWith(fieldName, value, exact);
```

| Parameter | Type | Description |
| - | - | - |
| **fieldName** | string | The field name in which to search |
| **value** | string | The **postfix** string to search by |
| **exact** | boolean | `false` - search is case-insensitive<br />`true` - search is case-sensitive |

## See also

- [Query overview](https://docs.ravendb.net/7.2/querying/overview.nodejs.md)
- [Starts-With query](https://docs.ravendb.net/7.2/client-api/session/querying/text-search/starts-with-query.nodejs.md)
- [Full-text search](https://docs.ravendb.net/7.2/client-api/session/querying/text-search/full-text-search.nodejs.md)
- [Map indexes](https://docs.ravendb.net/7.2/indexes/map-indexes.nodejs.md)
