Skip to content

Commit e9533fb

Browse files
Milvus-doc-botMilvus-doc-bot
authored andcommitted
Release new docs to preview
1 parent 18e2a05 commit e9533fb

2 files changed

Lines changed: 94 additions & 29 deletions

File tree

v3.0.x/site/en/userGuide/indexes/sparse/sparse-inverted-index.md

Lines changed: 89 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,83 @@ summary: "The SPARSE_INVERTED_INDEX index is an index type used by Milvus to eff
66

77
# SPARSE_INVERTED_INDEX
88

9-
The `SPARSE_INVERTED_INDEX` index is an index type used by Milvus to efficiently store and search sparse vectors. This index type leverages the principles of inverted indexing to create a highly efficient search structure for sparse data. For more information, refer to [INVERTED](inverted.md).
9+
The `SPARSE_INVERTED_INDEX` index is an index type used by Milvus to efficiently store and search sparse vectors. It builds an inverted structure from the non-zero dimensions in sparse vectors. You can use this index for BM25 full text search and for sparse embedding search based on inner product.
10+
11+
For more information about sparse vector fields, metric types, and full text search, refer to [Sparse Vector](sparse_vector.md), [Metric Types](metric.md), and [Full Text Search](full-text-search.md).
1012

1113
## Build index
1214

13-
To build a `SPARSE_INVERTED_INDEX` index on a sparse vector field in Milvus, use the `add_index()` method, specifying the `index_type`, `metric_type`, and additional parameters for the index.
15+
To build a `SPARSE_INVERTED_INDEX` index on a sparse vector field in Milvus, use the `add_index()` method and specify `index_type`, `metric_type`, and index parameters.
16+
17+
For BM25 full text search, build the index on the sparse vector field generated by a BM25 function. Set `metric_type` to `BM25`.
1418

1519
```python
1620
from pymilvus import MilvusClient
1721

22+
client = MilvusClient(uri="http://localhost:19530")
23+
1824
# Prepare index building params
19-
index_params = MilvusClient.prepare_index_params()
25+
index_params = client.prepare_index_params()
26+
index_params.add_index(
27+
field_name="sparse", # Name of the sparse vector field to index
28+
index_type="SPARSE_INVERTED_INDEX", # Type of the index to create
29+
index_name="sparse_bm25_index", # Name of the index to create
30+
metric_type="BM25", # Metric type used for full text search
31+
params={"inverted_index_algo": "DAAT_MAXSCORE"},
32+
)
2033

34+
client.create_index(
35+
collection_name="your_collection_name",
36+
index_params=index_params,
37+
)
38+
```
39+
40+
For sparse embedding search, build the index on a sparse vector field that stores externally generated sparse vectors. Set `metric_type` to `IP`.
41+
42+
```python
43+
# Prepare index building params
44+
index_params = client.prepare_index_params()
2145
index_params.add_index(
22-
field_name="your_sparse_vector_field_name", # Name of the vector field to be indexed
46+
field_name="sparse_vector", # Name of the sparse vector field to index
2347
index_type="SPARSE_INVERTED_INDEX", # Type of the index to create
24-
index_name="sparse_inverted_index", # Name of the index to create
48+
index_name="sparse_ip_index", # Name of the index to create
2549
metric_type="IP", # Metric type used to measure similarity
26-
params={"inverted_index_algo": "DAAT_MAXSCORE"}, # Algorithm used for building and querying the index
50+
params={"inverted_index_algo": "SINDI"},
51+
)
52+
53+
client.create_index(
54+
collection_name="your_collection_name",
55+
index_params=index_params,
2756
)
2857
```
2958

30-
In this configuration:
59+
In the preceding configurations:
3160

32-
- `index_type`: The type of index to be built. In this example, set the value to `SPARSE_INVERTED_INDEX`.
61+
- `index_type`: The type of index to build. Set this value to `SPARSE_INVERTED_INDEX`.
3362

3463
- `metric_type`: The metric used to calculate similarity between sparse vectors. Valid Values:
3564

36-
- `IP` (Inner Product): Measures similarity using dot product.
65+
- `BM25`: Uses BM25 relevance scoring for full text search.
3766

38-
- `BM25`: Typically used for full-text search, focusing on textual similarity.
67+
- `IP` (Inner Product): Measures sparse vector similarity using dot product.
3968

40-
For further details, refer to [Metric Types](metric.md) and [Full Text Search](full-text-search.md).
69+
For details, refer to [Metric Types](metric.md) and [Full Text Search](full-text-search.md).
4170

4271
- `params.inverted_index_algo`: The algorithm used for building and querying the index. Valid values:
4372

44-
- `"DAAT_MAXSCORE"` (default): Optimized Document-at-a-Time (DAAT) query processing using the MaxScore algorithm. MaxScore provides better performance for high *k* values or queries with many terms by skipping terms and documents likely to have minimal impact. It achieves this by partitioning terms into essential and non-essential groups based on their maximum impact scores, focusing on terms that can contribute to the top-k results.
73+
- `"DAAT_MAXSCORE"`: Document-at-a-Time MaxScore query processing. This is the default for `BM25`. For background, refer to [Query Evaluation: Strategies and Optimizations](https://dl.acm.org/doi/10.1016/0306-4573%2895%2900020-H).
74+
75+
- `"DAAT_WAND"`: Document-at-a-Time WAND query processing. This algorithm is suitable for smaller topK values or shorter queries. For background, refer to [Efficient Query Evaluation using a Two-Level Retrieval Process](https://dl.acm.org/doi/10.1145/956863.956944).
4576

46-
- `"DAAT_WAND"`: Optimized DAAT query processing using the WAND algorithm. WAND evaluates fewer hit documents by leveraging maximum impact scores to skip non-competitive documents, but it has a higher per-hit overhead. This makes WAND more efficient for queries with small *k* values or short queries, where skipping is more feasible.
77+
- `"TAAT_NAIVE"`: Basic Term-at-a-Time query processing. Use this option as a baseline or when you need scoring to adapt dynamically to global collection statistics such as average document length.
4778

48-
- `"TAAT_NAIVE"`: Basic Term-at-a-Time (TAAT) query processing. While it is slower compared to `DAAT_MAXSCORE` and `DAAT_WAND`, `TAAT_NAIVE` offers a unique advantage. Unlike DAAT algorithms, which use cached maximum impact scores that remain static regardless of changes to the global collection parameter (avgdl), `TAAT_NAIVE` dynamically adapts to such changes.
79+
- `"BLOCK_MAX_MAXSCORE"`: MaxScore query processing with block-level max-score metadata. For background, refer to [Faster Top-k Document Retrieval Using Block-Max Indexes](https://dl.acm.org/doi/10.1145/2009916.2010048).
80+
81+
- `"BLOCK_MAX_WAND"`: WAND query processing with block-level max-score metadata. For background, refer to [Faster Top-k Document Retrieval Using Block-Max Indexes](https://dl.acm.org/doi/10.1145/2009916.2010048).
82+
83+
- `"SINDI"`: A sparse inverted index based on fixed document-id windows, with SIMD acceleration for search. This is the default for `IP`. For details, refer to the [SINDI paper](https://arxiv.org/abs/2509.08395).
84+
85+
If you do not specify `inverted_index_algo`, Milvus selects the default algorithm based on `metric_type`: `DAAT_MAXSCORE` for `BM25`, and `SINDI` for `IP`.
4986

5087
To learn more building parameters available for the `SPARSE_INVERTED_INDEX` index, refer to [Index building params](sparse-inverted-index.md#Index-building-params).
5188

@@ -55,19 +92,36 @@ Once the index parameters are configured, you can create the index by using the
5592

5693
Once the index is built and entities are inserted, you can perform similarity searches on the index.
5794

95+
For BM25 full text search, use raw text as the query. Milvus converts the query text into a sparse vector through the BM25 function.
96+
97+
```python
98+
res = client.search(
99+
collection_name="your_collection_name",
100+
data=["what is information retrieval?"],
101+
anns_field="sparse",
102+
output_fields=["text"],
103+
limit=3,
104+
)
105+
```
106+
107+
For sparse embedding search, use a sparse-vector dictionary as the query vector.
108+
58109
```python
59110
# Prepare the query vector
60111
query_vector = [{1: 0.2, 50: 0.4, 1000: 0.7}]
61112

62-
res = MilvusClient.search(
63-
collection_name="your_collection_name", # Collection name
64-
anns_field="vector_field", # Vector field name
65-
data=query_vector, # Query vector
66-
limit=3, # TopK results to return
113+
res = client.search(
114+
collection_name="your_collection_name",
115+
anns_field="sparse_vector",
116+
data=query_vector,
117+
limit=3,
118+
search_params={"metric_type": "IP"},
67119
)
68120
```
69121

70-
To learn more search parameters available for the `SPARSE_INVERTED_INDEX` index, refer to [Index-specific search params](ivf-flat.md#share-KDWodFEx6oCm2yxgEUAcXaUDnwg).
122+
By default, Milvus uses the search algorithm configured for the index.
123+
124+
To learn more search parameters available for the `SPARSE_INVERTED_INDEX` index, refer to [Index-specific search params](sparse-inverted-index.md#Index-specific-search-params).
71125

72126
## Index params
73127

@@ -87,8 +141,20 @@ The following table lists the parameters that can be configured in `params` when
87141
<tr>
88142
<td><p><code>inverted_index_algo</code></p></td>
89143
<td><p>The algorithm used for building and querying the index. It determines how the index processes queries.</p></td>
90-
<td><p><code>"DAAT_MAXSCORE"</code> (default), <code>"DAAT_WAND"</code>, <code>"TAAT_NAIVE"</code></p></td>
91-
<td><p>Use <code>"DAAT_MAXSCORE"</code> for scenarios with high k values or queries with many terms, which can benefit from skipping non-competitive documents. </p><p>Choose <code>"DAAT_WAND"</code> for queries with small k values or short queries to leverage more efficient skipping.</p><p>Use <code>"TAAT_NAIVE"</code> if dynamic adjustment to collection changes (e.g., avgdl) is required.</p></td>
144+
<td><p><code>"DAAT_MAXSCORE"</code>, <code>"DAAT_WAND"</code>, <code>"TAAT_NAIVE"</code>, <code>"BLOCK_MAX_MAXSCORE"</code>, <code>"BLOCK_MAX_WAND"</code>, <code>"SINDI"</code></p><p>Default value: <code>"DAAT_MAXSCORE"</code> for <code>BM25</code>; <code>"SINDI"</code> for <code>IP</code>.</p></td>
145+
<td><p>Use <code>"DAAT_MAXSCORE"</code> for BM25 full text search workloads with high k values or queries with many terms.</p><p>Use <code>"DAAT_WAND"</code> for BM25 workloads with small k values or short queries.</p><p>Use <code>"TAAT_NAIVE"</code> as a baseline, or when you need scoring to adapt dynamically to global collection statistics such as average document length.</p><p>Use <code>"BLOCK_MAX_MAXSCORE"</code> or <code>"BLOCK_MAX_WAND"</code> to use block-level max-score metadata for query pruning.</p><p>Use <code>"SINDI"</code> for sparse embedding search with <code>IP</code>.</p></td>
146+
</tr>
147+
<tr>
148+
<td><p><code>bm25_k1</code></p></td>
149+
<td><p>Controls term frequency saturation for BM25 scoring. This parameter applies only when <code>metric_type</code> is <code>BM25</code>.</p></td>
150+
<td><p>Recommended range: [1.2, 2.0]</p><p>Default value: 1.2</p></td>
151+
<td><p>Increase this value to give term frequency more weight in document ranking.</p></td>
152+
</tr>
153+
<tr>
154+
<td><p><code>bm25_b</code></p></td>
155+
<td><p>Controls the strength of document length normalization for BM25 scoring. This parameter applies only when <code>metric_type</code> is <code>BM25</code>.</p></td>
156+
<td><p>Range: [0, 1]</p><p>Default value: 0.75</p></td>
157+
<td><p>Use a higher value to apply stronger length normalization. Use a lower value to reduce the effect of document length on ranking.</p></td>
92158
</tr>
93159
</table>
94160

@@ -106,8 +172,7 @@ The following table lists the parameters that can be configured in `search_param
106172
<tr>
107173
<td><p><code>drop_ratio_search</code></p></td>
108174
<td><p>The proportion of the smallest values to ignore during search, helping to reduce noise.</p></td>
109-
<td><p>Fraction between 0.0 and 1.0 (e.g., 0.2 ignores the smallest 20% of values)</p></td>
175+
<td><p>Range: [0.0, 1.0) (for example, 0.2 ignores the smallest 20% of values)</p></td>
110176
<td><p>Tune this parameter based on the sparsity and noise level of your query vectors.</p><p>This parameter controls the proportion of low-magnitude values dropped during search. Increasing this value (for example, to <code>0.2</code>) can reduce noise and focus the search on more significant components, which may improve precision and efficiency. However, dropping more values can also reduce recall by excluding potentially relevant signals. Choose a value that balances recall and accuracy for your workload.</p></td>
111177
</tr>
112178
</table>
113-

v3.0.x/site/en/userGuide/search-query-get/full-text-search.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export indexParams='[
430430
</tr>
431431
<tr>
432432
<td><p><code>index_type</code></p></td>
433-
<td><p>The type of the index to create. <code>AUTOINDEX</code> allows Milvus to automatically optimize index settings. If you need more control over your index settings, you can choose from various index types available for sparse vectors in Milvus. For more information, refer to <a href="index.md#Indexes-supported-in-Milvus">Indexes supported in Milvus</a>.</p></td>
433+
<td><p>The type of the index to create. For BM25 full text search in Milvus, set this value to <code>SPARSE_INVERTED_INDEX</code>. For more information, refer to <a href="sparse-inverted-index.md">SPARSE_INVERTED_INDEX</a>.</p></td>
434434
</tr>
435435
<tr>
436436
<td><p><code>metric_type</code></p></td>
@@ -442,15 +442,15 @@ export indexParams='[
442442
</tr>
443443
<tr>
444444
<td><p><code>params.inverted_index_algo</code></p></td>
445-
<td><p>The algorithm used for building and querying the index. Valid values:</p><ul><li><p><code>"DAAT_MAXSCORE"</code> (default): Optimized Document-at-a-Time (DAAT) query processing using the MaxScore algorithm. MaxScore provides better performance for high <em>k</em> values or queries with many terms by skipping terms and documents likely to have minimal impact. It achieves this by partitioning terms into essential and non-essential groups based on their maximum impact scores, focusing on terms that can contribute to the top-k results.</p></li><li><p><code>"DAAT_WAND"</code>: Optimized DAAT query processing using the WAND algorithm. WAND evaluates fewer hit documents by leveraging maximum impact scores to skip non-competitive documents, but it has a higher per-hit overhead. This makes WAND more efficient for queries with small <em>k</em> values or short queries, where skipping is more feasible.</p></li><li><p><code>"TAAT_NAIVE"</code>: Basic Term-at-a-Time (TAAT) query processing. While it is slower compared to <code>DAAT_MAXSCORE</code> and <code>DAAT_WAND</code>, <code>TAAT_NAIVE</code> offers a unique advantage. Unlike DAAT algorithms, which use cached maximum impact scores that remain static regardless of changes to the global collection parameter (avgdl), <code>TAAT_NAIVE</code> dynamically adapts to such changes.</p></li></ul></td>
445+
<td><p>The algorithm used for building and querying the BM25 sparse inverted index. Valid values:</p><ul><li><p><code>"DAAT_MAXSCORE"</code> (default): Document-at-a-Time MaxScore query processing. This option is suitable for full text search workloads with high <em>k</em> values or queries with many terms. For background, refer to <a href="https://dl.acm.org/doi/10.1016/0306-4573%2895%2900020-H">Query Evaluation: Strategies and Optimizations</a>.</p></li><li><p><code>"DAAT_WAND"</code>: Document-at-a-Time WAND query processing. This option is suitable for full text search workloads with small <em>k</em> values or short queries. For background, refer to <a href="https://dl.acm.org/doi/10.1145/956863.956944">Efficient Query Evaluation using a Two-Level Retrieval Process</a>.</p></li><li><p><code>"TAAT_NAIVE"</code>: Basic Term-at-a-Time query processing. Use this option as a baseline, or when you need scoring to adapt dynamically to global collection statistics such as average document length.</p></li><li><p><code>"BLOCK_MAX_MAXSCORE"</code>: MaxScore query processing with block-level max-score metadata. For background, refer to <a href="https://dl.acm.org/doi/10.1145/2009916.2010048">Faster Top-k Document Retrieval Using Block-Max Indexes</a>.</p></li><li><p><code>"BLOCK_MAX_WAND"</code>: WAND query processing with block-level max-score metadata. For background, refer to <a href="https://dl.acm.org/doi/10.1145/2009916.2010048">Faster Top-k Document Retrieval Using Block-Max Indexes</a>.</p></li></ul></td>
446446
</tr>
447447
<tr>
448448
<td><p><code>params.bm25_k1</code></p></td>
449-
<td><p>Controls the term frequency saturation. Higher values increase the importance of term frequencies in document ranking. Value range: [1.2, 2.0].</p></td>
449+
<td><p>Controls the term frequency saturation. Higher values increase the importance of term frequencies in document ranking. Recommended range: [1.2, 2.0]. Default value: 1.2.</p></td>
450450
</tr>
451451
<tr>
452452
<td><p><code>params.bm25_b</code></p></td>
453-
<td><p>Controls the extent to which document length is normalized. Values between 0 and 1 are typically used, with a common default around 0.75. A value of 1 means no length normalization, while a value of 0 means full normalization.</p></td>
453+
<td><p>Controls the extent to which document length is normalized. Values between 0 and 1 are typically used, with a default value of 0.75. A value of 0 means no length normalization, while a value of 1 means full length normalization.</p></td>
454454
</tr>
455455
</table>
456456

@@ -701,7 +701,7 @@ curl --request POST \
701701
</tr>
702702
<tr>
703703
<td><p><code>params.drop_ratio_search</code></p></td>
704-
<td><p>Proportion of low-importance terms to ignore during search. For details, refer to <a href="sparse_vector.md">Sparse Vector</a>.</p></td>
704+
<td><p>Proportion of low-importance terms to ignore during search. The value must be in the range [0.0, 1.0). For details, refer to <a href="sparse_vector.md">Sparse Vector</a>.</p></td>
705705
</tr>
706706
<tr>
707707
<td></td>

0 commit comments

Comments
 (0)