---
title: "Starts-With Query"
url: "https://docs.ravendb.net/6.2/client-api/session/querying/text-search/starts-with-query"
version: "6.2"
language: "python"
---

# Starts-With Query

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/querying/text-search/starts-with-query.md), [PHP](https://docs.ravendb.net/6.2/client-api/session/querying/text-search/starts-with-query.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/session/querying/text-search/starts-with-query.nodejs.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**
>
> - You can query for documents having a field that starts with some specified string.
>
> - Unless explicitly specified, the string comparisons are case-insensitive by default.
>
> - In this page:
>   - [StartsWith](#startswith)
>   - [StartsWith (case-sensitive)](#startswith-\(case-sensitive\))
>   - [Negate StartsWith](#negate-startswith)

## StartsWith

### Query

```python
products = list(
  session.query(object_type=Product)
  # Call 'where_starts_with' on the field
  # Pass the prefix to search by
  .where_starts_with("Name", "Ch")
)

# Results will contain only Product documents having a 'Name' field
# that starts with any case variation of 'ch'
```

### RQL

```sql
from "Products"
where startsWith(Name, "Ch")
```

## StartsWith (case-sensitive)

### Query

```python
products = list(
  session.query(object_type=Product)
  # Pass 'exact=True' to search for an EXACT prefix match
  .where_starts_with("Name", "Ch", exact=True)
)

# Results will contain only Product documents having a 'Name' field
# that starts with 'Ch'
```

### RQL

```sql
from "Products"
where exact(startsWith(Name, "Ch"))
```

## Negate StartsWith

### Query

```python
products = list(
  session.query(object_type=Product)
  # Negate next statement
  .not_()
  # Call 'where_starts_with' on the field
  # Pass the prefix to search by
  .where_starts_with("Name", "Ch")
)
# Results will contain only Product documents having a 'Name' field
# that does NOT start with 'ch' or any other case variations of it
```

### RQL

```sql
from "Products"
where (true and not startsWith(Name, "Ch"))
```

## See also

- [Query overview](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-query.python.md)
- [Ends-With query](https://docs.ravendb.net/6.2/client-api/session/querying/text-search/ends-with-query.python.md)
- [Full-text search](https://docs.ravendb.net/6.2/client-api/session/querying/text-search/full-text-search.python.md)
