---
title: "Session: Querying: How to use Lucene"
url: "https://docs.ravendb.net/6.2/client-api/session/querying/document-query/how-to-use-lucene"
version: "6.2"
language: "nodejs"
---

# Session: Querying: How to use Lucene

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/querying/document-query/how-to-use-lucene.md), [Java](https://docs.ravendb.net/6.2/client-api/session/querying/document-query/how-to-use-lucene.java.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."

Lucene flavored syntax can be used with the `whereLucene()` method, a part of the filtering methods available in `IDocumentQuery`.

## Syntax

```javascript
query.whereLucene(fieldName, whereClause, exact);
```

| Parameters | | |
| - | - | - |
| **fieldName** | string | Name of a field in an index (default field) |
| **whereClause** | string | Lucene-syntax based clause |
| **exact** | boolean | (optional, default false) Match exact |

## Example

### Node.js

```javascript
const companies = await session.advanced
  .documentQuery({ collection: "Companies" })
  .whereLucene("Name", "bistro")
  .all();
```

### RQL

```sql
from Companies 
where lucene(name, 'bistro')
```

## Advanced Usage

The `fieldName` argument corresponds to Lucene's default field convention. It is mandatory to pass it to the `whereLucene()` but the `whereClause` can contain clause that omits the field entirely giving you the opportunity to pass a complex expression e.g. `.whereLucene("name", "name:bistro OR phone:981-443655")`. It is advised to use this approach against Static Index where all fields are known, because there is no guarantee that a proper Auto Index will be created or used.

## See also

- [What is Document Query](https://docs.ravendb.net/6.2/client-api/session/querying/document-query/what-is-document-query.nodejs.md)
