Read one level up: https://search.qdrant.tech/md/documentation/search

> Explore Qdrant's agent skills catalog at https://skills.qdrant.tech/
> Search the documentation at https://skills.qdrant.tech/search?query=your+query+here
> Use this file for an index of the main pages: https://qdrant.tech/llms.txt


# Text Search

Qdrant is a vector search engine, making it a great tool for [semantic search](?s=semantic-search). However, Qdrant's capabilities go beyond just vector search. It also supports a range of lexical search features, including filtering on text fields and full-text search using popular algorithms like BM25.

## Semantic Search

Semantic search is a search technique that focuses on the meaning of the text rather than just matching on keywords. This is achieved by converting text into [vectors](https://qdrant.tech/documentation/manage-data/vectors/index.md) (embeddings) using machine learning models. These vectors capture the semantic meaning of the text, enabling you to find similar text even if it doesn't share exact keywords.

<aside role="status">
The examples in this guide use <a href="/documentation/inference/">inference</a> to let Qdrant generate the vectors. Inference is only available on <a href="/documentation/inference/cloud-inference/">Qdrant Cloud</a>. If you are not running on Qdrant Cloud, you can use a library like <a href="/documentation/fastembed/">FastEmbed</a> to generate vectors on the client side. When using FastEmbed, refer to the documentation, as its API may differ from that of server-side inference.
</aside>

For example, to search through a collection of books, you could use a model like the `all-MiniLM-L6-v2` sentence transformer model. First, create a collection and configure a dense vector for the book descriptions:

```http
PUT /collections/books
{
  "vectors": {
    "description-dense": {
      "size": 384,
      "distance": "Cosine"
    }
  }
}
```
> This snippet is also available in Python, Typescript, Rust, Java, Csharp, and Go. See the [full snippet](https://qdrant.tech/documentation/snippets/text-search/create-description-dense-collection/index.md).


Next, you can ingest data:

```http
PUT /collections/books/points?wait=true
{
  "points": [
    {
      "id": 1,
      "vector": {
        "description-dense": {
          "text": "A Victorian scientist builds a device to travel far into the future and observes the dim trajectories of humanity. He discovers evolutionary divergence and the consequences of class division. Wells's novella established time travel as a vehicle for social commentary.",
          "model": "sentence-transformers/all-minilm-l6-v2"
        }
      },
      "payload": {
        "title": "The Time Machine",
        "author": "H.G. Wells",
        "isbn": "9780553213515"
      }
    }
  ]
}
```
> This snippet is also available in Python, Typescript, Rust, Java, Csharp, and Go. See the [full snippet](https://qdrant.tech/documentation/snippets/text-search/ingest-description-dense-point/index.md).


To find books related to "time travel", use the following query:

```http
POST /collections/books/points/query
{
  "query": {
    "text": "time travel",
    "model": "sentence-transformers/all-minilm-l6-v2"
  },
  "using": "description-dense",
  "with_payload": true
}
```
> This snippet is also available in Python, Typescript, Rust, Java, Csharp, and Go. See the [full snippet](https://qdrant.tech/documentation/snippets/text-search/query-description-dense/index.md).


In these examples, Qdrant uses [inference](https://qdrant.tech/documentation/inference/index.md) to generate vectors from the `text` provided in the request using the specified `model`. Alternatively, you can generate explicit vectors on the client side with a library like [FastEmbed](https://qdrant.tech/documentation/fastembed/index.md).

## Lexical Search

Lexical search, also known as keyword-based search, is a traditional search technique that relies on matching words or phrases in the text. Many applications require a combination of semantic and traditional lexical search. A good example is in e-commerce, where users may want to search for products using a product ID. ID values don't lend themselves well to vectorization, but being able to search for them is essential for a good search experience.

Qdrant supports several types of lexical search:

- [Text filtering](https://qdrant.tech/documentation/search/text-search/text-filtering/index.md) narrows down results to points whose text contains specific words, phrases, or exact strings, such as product IDs.
- [Full-text search](https://qdrant.tech/documentation/search/text-search/full-text-search/index.md) ranks points by how relevant their text is to a query, using the BM25 ranking function.
- [Sparse vector search](https://qdrant.tech/documentation/search/text-search/sparse-vector-search/index.md) ranks points with learned sparse models like SPLADE++ and miniCOIL, which also capture meaning, such as synonyms.

Full-text filtering and full-text search both work on a [full-text index](https://qdrant.tech/documentation/manage-data/indexing/index.md#full-text-index) on the payload field that holds the text, so you don't need to generate embeddings. For example, to search the book titles, create a full-text index with BM25 scoring enabled on the `title` field:


**Qdrant Server:**

```http
PUT /collections/books/index?wait=true
{
  "field_name": "title",
  "field_schema": {
    "type": "text",
    "scoring": true
  }
}
```

> This snippet is also available in Python, Typescript, Rust, Java, Csharp, and Go for Qdrant Server; and in Python and Rust for Qdrant Edge. See the [full snippet](https://qdrant.tech/documentation/snippets/text-search/create-title-bm25-index/index.md).


To find books with "time travel" in the title, use the following query:


**Qdrant Server:**

```http
POST /collections/books/points/query
{
  "query": {
    "text": "time travel"
  },
  "using": "title",
  "limit": 10,
  "with_payload": true
}
```

> This snippet is also available in Python, Typescript, Rust, Java, Csharp, and Go for Qdrant Server; and in Python and Rust for Qdrant Edge. See the [full snippet](https://qdrant.tech/documentation/snippets/text-search/query-title-bm25/index.md).


## Filtering Versus Querying

When it comes to lexical search in Qdrant, it's important to distinguish between filtering and querying. Filtering is used to narrow down results based on exact matches or specific criteria, while querying involves finding relevant documents based on the content of the text. In other words, filtering is about precision, while querying is about recall. A filter does not contribute to the ranking of search results, as no score is calculated for filters. A query calculates a relevance score for each matching document and that score is used to rank search results.

| Filter | Query |
|---|---|
| Does not contribute to ranking | Contributes to ranking |
| Improves precision by narrowing down results | Improves recall by finding relevant data |

A full-text index supports both. Use [full-text match conditions](https://qdrant.tech/documentation/search/filtering/index.md#full-text-match) to filter on text, and enable [BM25 scoring](https://qdrant.tech/documentation/manage-data/indexing/index.md#bm25-scoring) on the index to rank points with a [`text` query](https://qdrant.tech/documentation/search/text-search/full-text-search/index.md#query-a-text-field).

## Combining Semantic and Lexical Search

Semantic and lexical search are complementary techniques. When you don't know in advance whether a user is looking for a concept or an exact keyword, you can run both in a single query and merge the results. Qdrant supports this through [hybrid search](https://qdrant.tech/documentation/search/text-search/hybrid-search/index.md).

## Subsites to Search

https://search.qdrant.tech/md/documentation/search/text-search/full-text-search
https://search.qdrant.tech/md/documentation/search/text-search/hybrid-search
https://search.qdrant.tech/md/documentation/search/text-search/sparse-vector-search
https://search.qdrant.tech/md/documentation/search/text-search/text-filtering