Skip to content

Commit d5a10a0

Browse files
Merge branch 'main' into tvbs90818
2 parents 0c95761 + e876dc0 commit d5a10a0

File tree

108 files changed

+2253
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+2253
-424
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/QueryPlanningBenchmark.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public void setup() {
9292
var fields = 10_000;
9393
var mapping = LinkedHashMap.<String, EsField>newLinkedHashMap(fields);
9494
for (int i = 0; i < fields; i++) {
95-
mapping.put("field" + i, new EsField("field-" + i, TEXT, emptyMap(), true));
95+
// We're creating a standard index, so none of these fields should be marked as dimensions.
96+
mapping.put("field" + i, new EsField("field-" + i, TEXT, emptyMap(), true, EsField.TimeSeriesFieldType.NONE));
9697
}
9798

9899
var esIndex = new EsIndex("test", mapping, Map.of("test", IndexMode.STANDARD));

benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/EvalBenchmark.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
212212
FieldAttribute timestamp = new FieldAttribute(
213213
Source.EMPTY,
214214
"timestamp",
215-
new EsField("timestamp", DataType.DATETIME, Map.of(), true)
215+
new EsField("timestamp", DataType.DATETIME, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
216216
);
217217
yield EvalMapper.toEvaluator(
218218
FOLD_CONTEXT,
@@ -321,19 +321,35 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
321321
}
322322

323323
private static FieldAttribute longField() {
324-
return new FieldAttribute(Source.EMPTY, "long", new EsField("long", DataType.LONG, Map.of(), true));
324+
return new FieldAttribute(
325+
Source.EMPTY,
326+
"long",
327+
new EsField("long", DataType.LONG, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
328+
);
325329
}
326330

327331
private static FieldAttribute doubleField() {
328-
return new FieldAttribute(Source.EMPTY, "double", new EsField("double", DataType.DOUBLE, Map.of(), true));
332+
return new FieldAttribute(
333+
Source.EMPTY,
334+
"double",
335+
new EsField("double", DataType.DOUBLE, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
336+
);
329337
}
330338

331339
private static FieldAttribute intField() {
332-
return new FieldAttribute(Source.EMPTY, "int", new EsField("int", DataType.INTEGER, Map.of(), true));
340+
return new FieldAttribute(
341+
Source.EMPTY,
342+
"int",
343+
new EsField("int", DataType.INTEGER, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
344+
);
333345
}
334346

335347
private static FieldAttribute keywordField() {
336-
return new FieldAttribute(Source.EMPTY, "keyword", new EsField("keyword", DataType.KEYWORD, Map.of(), true));
348+
return new FieldAttribute(
349+
Source.EMPTY,
350+
"keyword",
351+
new EsField("keyword", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
352+
);
337353
}
338354

339355
private static Configuration configuration() {

catalog-info.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ spec:
306306
apiVersion: backstage.io/v1alpha1
307307
kind: Resource
308308
metadata:
309-
name: buildkite-pipeline-elasticsearch-pull-request-performance-benchmark
309+
name: buildkite-pipeline-elasticsearch-pull-request-perf-benchmark
310310
description: Elasticsearch pull request performance benchmark
311311
links:
312312
- title: Pipeline

docs/changelog/132774.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 132774
2+
summary: Improve cpu utilization with dynamic slice size in doc partitioning
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/132845.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 132845
2+
summary: Expose existing DLS cache x-pack usage statistics
3+
area: Authorization
4+
type: enhancement
5+
issues: []

docs/changelog/132858.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 132858
2+
summary: Add index mode to resolve index response
3+
area: Indices APIs
4+
type: feature
5+
issues: []

docs/changelog/132945.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 132945
2+
summary: Disable child span for streaming tasks
3+
area: Machine Learning
4+
type: bug
5+
issues: []

docs/changelog/133021.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 133021
2+
summary: Fix update expiration for async query
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 130619

docs/reference/elasticsearch-plugins/plugin-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ If Elasticsearch was installed using the deb or rpm package then run `/usr/share
116116

117117
For detailed instructions on installing, managing, and configuring plugins, see the following:
118118

119-
* [Intalling Plugings](./installation.md)
119+
* [Installing Plugins](./installation.md)
120120
* [Custom URL or file system](./plugin-management-custom-url.md)
121121
* [Installing multiple plugins](./installing-multiple-plugins.md)
122122
* [Mandatory plugins](./mandatory-plugins.md)
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
navigation_title: Better Binary Quantization (BBQ)
3+
applies_to:
4+
stack: all
5+
serverless: all
6+
---
7+
8+
# Better Binary Quantization (BBQ) [bbq]
9+
10+
Better Binary Quantization (BBQ) is an advanced vector quantization method, designed for large-scale similarity search. BBQ is a form of lossy compression for [`dense_vector` fields](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/dense-vector) that enables efficient storage and retrieval of large numbers of vectors, while keeping results close to those from the original uncompressed vectors.
11+
12+
BBQ offers significant improvements over scalar quantization by relying on optimized `bit` level computations to reduce memory usage and computational costs while maintaining high search relevance using pre-computed corrective factors. BBQ is designed to work in combination with [oversampling](#bbq-oversampling) and reranking, and is compatible with various [vector search algorithms](#bbq-vector-search-algorithms), such as [HNSW](#bbq-hnsw) and [brute force (flat)](#bbq-flat).
13+
14+
## How BBQ works [bbq-how-it-works]
15+
16+
BBQ retains the original vector’s dimensionality but transforms the datatype of the dimensions from the original `float32` to `bit` effectively compressing each vector by 32x plus an additional 14 bytes of corrective data per vector. BBQ uses these pre-computed corrective factors as partial distance calculations to help realize impressively robust approximations of the original vector.
17+
18+
Measuring vector similarity with BBQ vectors requires much less computing effort, allowing more candidates to be considered when using the HNSW algorithm. This often results in better ranking quality and improved relevance compared to the original `float32` vectors.
19+
20+
## Supported vector search algorithms [bbq-vector-search-algorithms]
21+
22+
BBQ currently supports two vector search algorithms, each suited to different scenarios. You can configure them by setting the dense vector field’s `index_type`.
23+
24+
### `bbq_hnsw` [bbq-hnsw]
25+
26+
When you set a dense vector field’s `index_options` parameter to `type: bbq_hnsw`, {{es}} uses the HNSW algorithm for fast [kNN search](https://www.elastic.co/docs//solutions/search/vector/knn) on compressed vectors. With the default [oversampling](#bbq-oversampling) applied, it delivers better cost efficiency, lower latency, and improved relevance ranking, making it the best choice for large-scale similarity search.
27+
28+
:::{note}
29+
Starting in version 9.1, `bbq_hnsw` is the default indexing method for new `dense_vector` fields with greater than 384 dimensions, so you typically don’t need to specify it explicitly when creating an index.
30+
31+
Datasets with less than 384 dimensions may see less accuracy and incur a higher overhead cost related to the corrective factors, but we have observed some production datasets perform well even at fairly low dimensions including [tests on e5-small](https://www.elastic.co/search-labs/blog/better-binary-quantization-lucene-elasticsearch).
32+
:::
33+
34+
The following example creates an index with a `dense_vector` field configured to use the `bbq_hnsw` algorithm.
35+
36+
```console
37+
PUT bbq_hnsw-index
38+
{
39+
"mappings": {
40+
"properties": {
41+
"my_vector": {
42+
"type": "dense_vector",
43+
"dims": 64,
44+
"index": true,
45+
"index_options": {
46+
"type": "bbq_hnsw"
47+
}
48+
}
49+
}
50+
}
51+
}
52+
```
53+
54+
To change an existing index to use `bbq_hnsw`, update the field mapping:
55+
56+
```console
57+
PUT bbq_hnsw-index/_mapping
58+
{
59+
"properties": {
60+
"my_vector": {
61+
"type": "dense_vector",
62+
"dims": 64,
63+
"index": true,
64+
"index_options": {
65+
"type": "bbq_hnsw"
66+
}
67+
}
68+
}
69+
}
70+
```
71+
72+
After this change, all newly created segments will use the `bbq_hnsw` algorithm. As you add or update documents, the index will gradually convert to `bbq_hnsw`.
73+
74+
To apply `bbq_hnsw` to all vectors at once, reindex them into a new index where the `index_options` parameter's `type` is set to `bbq_hnsw`:
75+
76+
:::::{stepper}
77+
::::{step} Create a destination index
78+
```console
79+
PUT my-index-bbq
80+
{
81+
"mappings": {
82+
"properties": {
83+
"my_vector": {
84+
"type": "dense_vector",
85+
"dims": 64,
86+
"index": true,
87+
"index_options": {
88+
"type": "bbq_hnsw"
89+
}
90+
}
91+
}
92+
}
93+
}
94+
```
95+
::::
96+
97+
::::{step} Reindex the data
98+
```console
99+
POST _reindex
100+
{
101+
"source": { "index": "my-index" }, <1>
102+
"dest": { "index": "my-index-bbq" }
103+
}
104+
```
105+
1. The existing index to be reindexed into the newly created index with the `bbq_hnsw` algorithm.
106+
::::
107+
108+
:::::
109+
110+
### `bbq_flat` [bbq-flat]
111+
112+
When you set a dense vector field’s `index_options` parameter to `type: bbq_flat`, {{es}} uses the BBQ algorithm without HNSW. This option generally requires fewer computing resources and works best when the number of vectors being searched is relatively low.
113+
114+
The following example creates an index with a `dense_vector` field configured to use the `bbq_flat` algorithm.
115+
116+
```console
117+
PUT bbq_flat-index
118+
{
119+
"mappings": {
120+
"properties": {
121+
"my_vector": {
122+
"type": "dense_vector",
123+
"dims": 64,
124+
"index": true,
125+
"index_options": {
126+
"type": "bbq_flat"
127+
}
128+
}
129+
}
130+
}
131+
}
132+
```
133+
134+
## Oversampling [bbq-oversampling]
135+
136+
Oversampling is a technique used with BBQ searches to reduce the accuracy loss from compression. Compression lowers the memory footprint by over 95% and improves query latency, at the cost of decreased result accuracy. This decrease can be mitigated by oversampling during query time and reranking the top results using the full vector.
137+
138+
When you run a kNN search on a BBQ-indexed field, {{es}} automatically retrieves more candidate vectors than the number of results you request. This oversampling improves accuracy by giving the system more vectors to re-rank using their full-precision values before returning the top results.
139+
140+
```console
141+
GET bbq-index/_search
142+
{
143+
"knn": {
144+
"field": "my_vector",
145+
"query_vector": [0.12, -0.45, ...],
146+
"k": 10,
147+
"num_candidates": 100
148+
}
149+
}
150+
```
151+
152+
By default, oversampling is set to 3×, meaning if you request k:10, {{es}} retrieves 30 candidates for re-ranking. You don’t need to configure this behavior; it’s applied automatically for BBQ searches.
153+
154+
:::{note}
155+
You can change oversampling from the default 3× to another value. Refer to [Oversampling and rescoring for quantized vectors](https://www.elastic.co/docs/solutions/search/vector/knn#dense-vector-knn-search-rescoring) for details.
156+
:::
157+
158+
## Learn more [bbq-learn-more]
159+
160+
- [Better Binary Quantization (BBQ) in Lucene and {{es}}](https://www.elastic.co/search-labs/blog/better-binary-quantization-lucene-elasticsearch) - Learn how BBQ works, its benefits, and how it reduces memory usage while preserving search accuracy.
161+
- [Dense vector field type](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/dense-vector) - Find code examples for using `bbq_hnsw` `index_type`.
162+
- [kNN search](https://www.elastic.co/docs/solutions/search/vector/knn) - Learn about the search algorithm that BBQ works with.

0 commit comments

Comments
 (0)