> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lambdadb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sparse vector query

> Search LambdaDB using sparse vector representations from learned sparse retrieval models. Pass precalculated token-weight pairs for precise matching.

A sparse vector query executes search using sparse vector representations, typically generated by learned sparse retrieval models.
You must provide precalculated token-weight pairs as your query vectors, where each pair represents a term and its corresponding relevance score.

> [!NOTE]
>
> Currently, LambdaDB does not support built-in natural language processing models for automatic sparse vector generation.

## Parameters

| Parameter | Description | Type | Required |
| :- | :- | :- | :- |
| field | The name of the vector field to search against | string | ✓ |
| queryVector | Query vector as token-weight pairs | object | ✓ |

## Scoring and limits

Sparse retrieval uses linear scoring over shared terms: each matching term contributes the stored document weight multiplied by the query weight, and the contributions are added. Terms present in only one vector contribute nothing. This is separate from BM25 text scoring and dense-vector cosine similarity; sparse weights do not need to sum to one or have unit length.

Query vectors must fit the [entry-count and weight limits](https://docs.lambdadb.ai/guides/get-started/limits.md#search-and-reads). Keys must use the same token or index representation as the stored vectors; numeric index keys are strings in JSON. LambdaDB does not generate these vectors or translate between vocabularies.

The returned retrieval `score` is not a relevance probability and is not constrained to \[0,1]. Hybrid fusion normalizes the retrieval scores, while applied native reranking replaces the final `score` and retains the sparse or fused value in `retrievalScore`.

## Examples

The examples are query objects. Place them under the request body's top-level `query`, alongside `size` and other [search options](https://docs.lambdadb.ai/guides/search/search-overview.md). Sparse retrieval has no `knn.k` parameter; see [reranking candidate counts](https://docs.lambdadb.ai/guides/search/native-reranking.md#candidate-counts) when adding native reranking.

### Token-based sparse vector query

```json theme={null}
{
  "sparseVector": {
    "field": "example_sparse_field",
    "queryVector": {
      "LambdaDB": 0.5,
      "awesome": 0.3,
      "AI": 0.2
    }
  }
}
```

### Index-based sparse vector query

If you prefer to use the index-based format with separate values and index arrays, you can specify index positions as keys in the queryVector object:

```json theme={null}
{
  "sparseVector": {
    "field": "example_sparse_field",
    "queryVector": {
      "10": 0.5,
      "45": 0.3,
      "234": 0.2
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.