Skip to content

Commit 1c9edbd

Browse files
authored
Merge branch 'main' into remove-estimated-row-size-assertion
2 parents bef38ef + db5acd8 commit 1c9edbd

File tree

80 files changed

+500
-226
lines changed

Some content is hidden

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

80 files changed

+500
-226
lines changed

docs/changelog/122933.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 122933
2+
summary: Run XPack usage actions on local node
3+
area: Stats
4+
type: enhancement
5+
issues: []
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
navigation_title: "Rank Vectors"
3+
mapped_pages:
4+
- https://www.elastic.co/guide/en/elasticsearch/reference/master/rank-vectors.html
5+
---
6+
7+
# Rank Vectors [rank-vectors]
8+
9+
10+
::::{warning}
11+
This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
12+
::::
13+
14+
15+
The `rank_vectors` field type enables late-interaction dense vector scoring in Elasticsearch. The number of vectors per field can vary, but they must all share the same number of dimensions and element type.
16+
17+
The purpose of vectors stored in this field is second order ranking documents with max-sim similarity.
18+
19+
Here is a simple example of using this field with `float` elements.
20+
21+
```console
22+
PUT my-rank-vectors-float
23+
{
24+
"mappings": {
25+
"properties": {
26+
"my_vector": {
27+
"type": "rank_vectors"
28+
}
29+
}
30+
}
31+
}
32+
33+
PUT my-rank-vectors-float/_doc/1
34+
{
35+
"my_vector" : [[0.5, 10, 6], [-0.5, 10, 10]]
36+
}
37+
```
38+
39+
In addition to the `float` element type, `byte` and `bit` element types are also supported.
40+
41+
Here is an example of using this field with `byte` elements.
42+
43+
```console
44+
PUT my-rank-vectors-byte
45+
{
46+
"mappings": {
47+
"properties": {
48+
"my_vector": {
49+
"type": "rank_vectors",
50+
"element_type": "byte"
51+
}
52+
}
53+
}
54+
}
55+
56+
PUT my-rank-vectors-byte/_doc/1
57+
{
58+
"my_vector" : [[1, 2, 3], [4, 5, 6]]
59+
}
60+
```
61+
62+
Here is an example of using this field with `bit` elements.
63+
64+
```console
65+
PUT my-rank-vectors-bit
66+
{
67+
"mappings": {
68+
"properties": {
69+
"my_vector": {
70+
"type": "rank_vectors",
71+
"element_type": "bit"
72+
}
73+
}
74+
}
75+
}
76+
77+
POST /my-rank-vectors-bit/_bulk?refresh
78+
{"index": {"_id" : "1"}}
79+
{"my_vector": [127, -127, 0, 1, 42]}
80+
{"index": {"_id" : "2"}}
81+
{"my_vector": "8100012a7f"}
82+
```
83+
84+
## Parameters for rank vectors fields [rank-vectors-params]
85+
86+
The `rank_vectors` field type supports the following parameters:
87+
88+
$$$rank-vectors-element-type$$$
89+
90+
`element_type`
91+
: (Optional, string) The data type used to encode vectors. The supported data types are `float` (default), `byte`, and bit.
92+
93+
::::{dropdown} Valid values for `element_type`
94+
`float`
95+
: indexes a 4-byte floating-point value per dimension. This is the default value.
96+
97+
`byte`
98+
: indexes a 1-byte integer value per dimension.
99+
100+
`bit`
101+
: indexes a single bit per dimension. Useful for very high-dimensional vectors or models that specifically support bit vectors. NOTE: when using `bit`, the number of dimensions must be a multiple of 8 and must represent the number of bits.
102+
103+
::::
104+
105+
106+
`dims`
107+
: (Optional, integer) Number of vector dimensions. Can’t exceed `4096`. If `dims` is not specified, it will be set to the length of the first vector added to the field.
108+
109+
110+
## Synthetic `_source` [rank-vectors-synthetic-source]
111+
112+
::::{important}
113+
Synthetic `_source` is Generally Available only for TSDB indices (indices that have `index.mode` set to `time_series`). For other indices synthetic `_source` is in technical preview. Features in technical preview may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
114+
::::
115+
116+
117+
`rank_vectors` fields support [synthetic `_source`](mapping-source-field.md#synthetic-source) .
118+
119+
120+
## Scoring with rank vectors [rank-vectors-scoring]
121+
122+
Rank vectors can be accessed and used in [`script_score` queries](/reference/query-languages/query-dsl-script-score-query.md).
123+
124+
For example, the following query scores documents based on the maxSim similarity between the query vector and the vectors stored in the `my_vector` field:
125+
126+
```console
127+
GET my-rank-vectors-float/_search
128+
{
129+
"query": {
130+
"script_score": {
131+
"query": {
132+
"match_all": {}
133+
},
134+
"script": {
135+
"source": "maxSimDotProduct(params.query_vector, 'my_vector')",
136+
"params": {
137+
"query_vector": [[0.5, 10, 6], [-0.5, 10, 10]]
138+
}
139+
}
140+
}
141+
}
142+
}
143+
```
144+
145+
Additionally, asymmetric similarity functions can be used to score against `bit` vectors. For example, the following query scores documents based on the maxSimDotProduct similarity between a floating point query vector and bit vectors stored in the `my_vector` field:
146+
147+
```console
148+
PUT my-rank-vectors-bit
149+
{
150+
"mappings": {
151+
"properties": {
152+
"my_vector": {
153+
"type": "rank_vectors",
154+
"element_type": "bit"
155+
}
156+
}
157+
}
158+
}
159+
160+
POST /my-rank-vectors-bit/_bulk?refresh
161+
{"index": {"_id" : "1"}}
162+
{"my_vector": [127, -127, 0, 1, 42]}
163+
{"index": {"_id" : "2"}}
164+
{"my_vector": "8100012a7f"}
165+
166+
GET my-rank-vectors-bit/_search
167+
{
168+
"query": {
169+
"script_score": {
170+
"query": {
171+
"match_all": {}
172+
},
173+
"script": {
174+
"source": "maxSimDotProduct(params.query_vector, 'my_vector')",
175+
"params": {
176+
"query_vector": [
177+
[0.35, 0.77, 0.95, 0.15, 0.11, 0.08, 0.58, 0.06, 0.44, 0.52, 0.21,
178+
0.62, 0.65, 0.16, 0.64, 0.39, 0.93, 0.06, 0.93, 0.31, 0.92, 0.0,
179+
0.66, 0.86, 0.92, 0.03, 0.81, 0.31, 0.2 , 0.92, 0.95, 0.64, 0.19,
180+
0.26, 0.77, 0.64, 0.78, 0.32, 0.97, 0.84]
181+
] <1>
182+
}
183+
}
184+
}
185+
}
186+
}
187+
```
188+
189+
1. Note that the query vector has 40 elements, matching the number of bits in the bit vectors.
190+
191+
192+

docs/reference/toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ toc:
140140
- file: elasticsearch/mapping-reference/range.md
141141
- file: elasticsearch/mapping-reference/rank-feature.md
142142
- file: elasticsearch/mapping-reference/rank-features.md
143+
- file: elasticsearch/mapping-reference/rank-vectors.md
143144
- file: elasticsearch/mapping-reference/search-as-you-type.md
144145
- file: elasticsearch/mapping-reference/semantic-text.md
145146
- file: elasticsearch/mapping-reference/shape.md

docs/release-notes/index.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@ navigation_title: "Elasticsearch"
33
mapped_pages:
44
- https://www.elastic.co/guide/en/elasticsearch/reference/current/es-connectors-release-notes.html
55
- https://www.elastic.co/guide/en/elasticsearch/reference/current/es-release-notes.html
6+
- https://www.elastic.co/guide/en/elasticsearch/reference/master/release-notes-9.0.0.html
7+
- https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-9.0.html
68
---
79

810
# Elasticsearch release notes [elasticsearch-release-notes]
911

10-
Review the changes, fixes, and more in each version of Elasticsearch.
12+
Review the changes, fixes, and more in each version of Elasticsearch.
1113

1214
To check for security updates, go to [Security announcements for the Elastic stack](https://discuss.elastic.co/c/announcements/security-announcements/31).
1315

14-
% Release notes include only features, enhancements, and fixes. Add breaking changes, deprecations, and known issues to the applicable release notes sections.
16+
% Release notes include only features, enhancements, and fixes. Add breaking changes, deprecations, and known issues to the applicable release notes sections.
1517

1618
% ## version.next [felasticsearch-next-release-notes]
1719
% **Release date:** Month day, year
1820

1921
% ### Features and enhancements [elasticsearch-next-features-enhancements]
20-
% *
22+
% *
2123

2224
% ### Fixes [elasticsearch-next-fixes]
23-
% *
25+
% *
2426

2527
## 9.0.0 [elasticsearch-900-release-notes]
2628
**Release date:** March 25, 2025

libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.entitlement.runtime.policy;
1111

1212
import org.elasticsearch.common.settings.Settings;
13+
import org.elasticsearch.core.Strings;
1314
import org.elasticsearch.entitlement.runtime.policy.PolicyManager.ModuleEntitlements;
1415
import org.elasticsearch.entitlement.runtime.policy.agent.TestAgent;
1516
import org.elasticsearch.entitlement.runtime.policy.agent.inner.TestInnerAgent;
@@ -411,6 +412,9 @@ public void testDuplicateEntitlements() {
411412
}
412413

413414
public void testFilesEntitlementsWithExclusive() {
415+
var baseTestPath = Path.of("/tmp").toAbsolutePath();
416+
var testPath1 = Path.of("/tmp/test").toAbsolutePath();
417+
var testPath2 = Path.of("/tmp/test/foo").toAbsolutePath();
414418
var iae = expectThrows(
415419
IllegalArgumentException.class,
416420
() -> new PolicyManager(
@@ -425,10 +429,7 @@ public void testFilesEntitlementsWithExclusive() {
425429
"test",
426430
List.of(
427431
new FilesEntitlement(
428-
List.of(
429-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test"), FilesEntitlement.Mode.READ)
430-
.withExclusive(true)
431-
)
432+
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
432433
)
433434
)
434435
)
@@ -442,10 +443,7 @@ public void testFilesEntitlementsWithExclusive() {
442443
"test",
443444
List.of(
444445
new FilesEntitlement(
445-
List.of(
446-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test"), FilesEntitlement.Mode.READ)
447-
.withExclusive(true)
448-
)
446+
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
449447
)
450448
)
451449
)
@@ -460,7 +458,7 @@ public void testFilesEntitlementsWithExclusive() {
460458
)
461459
);
462460
assertTrue(iae.getMessage().contains("duplicate/overlapping exclusive paths found in files entitlements:"));
463-
assertTrue(iae.getMessage().contains("[test] [/tmp/test]]"));
461+
assertTrue(iae.getMessage().contains(Strings.format("[test] [%s]]", testPath1.toString())));
464462

465463
iae = expectThrows(
466464
IllegalArgumentException.class,
@@ -473,9 +471,8 @@ public void testFilesEntitlementsWithExclusive() {
473471
List.of(
474472
new FilesEntitlement(
475473
List.of(
476-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test/foo"), FilesEntitlement.Mode.READ)
477-
.withExclusive(true),
478-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/"), FilesEntitlement.Mode.READ)
474+
FilesEntitlement.FileData.ofPath(testPath2, FilesEntitlement.Mode.READ).withExclusive(true),
475+
FilesEntitlement.FileData.ofPath(baseTestPath, FilesEntitlement.Mode.READ)
479476
)
480477
)
481478
)
@@ -492,10 +489,7 @@ public void testFilesEntitlementsWithExclusive() {
492489
"test",
493490
List.of(
494491
new FilesEntitlement(
495-
List.of(
496-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test"), FilesEntitlement.Mode.READ)
497-
.withExclusive(true)
498-
)
492+
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
499493
)
500494
)
501495
)
@@ -510,8 +504,12 @@ public void testFilesEntitlementsWithExclusive() {
510504
)
511505
);
512506
assertEquals(
513-
"duplicate/overlapping exclusive paths found in files entitlements: "
514-
+ "[[plugin1] [test] [/tmp/test]] and [[(server)] [test] [/tmp/test/foo]]",
507+
Strings.format(
508+
"duplicate/overlapping exclusive paths found in files entitlements: "
509+
+ "[[plugin1] [test] [%s]] and [[(server)] [test] [%s]]",
510+
testPath1,
511+
testPath2
512+
),
515513
iae.getMessage()
516514
);
517515
}

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ tests:
329329
- class: org.elasticsearch.action.admin.cluster.node.tasks.CancellableTasksIT
330330
method: testChildrenTasksCancelledOnTimeout
331331
issue: https://github.com/elastic/elasticsearch/issues/123568
332-
- class: org.elasticsearch.entitlement.runtime.policy.PolicyManagerTests
333-
method: testFilesEntitlementsWithExclusive
334-
issue: https://github.com/elastic/elasticsearch/issues/123657
335332
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
336333
method: test {p0=search.vectors/41_knn_search_bbq_hnsw/Test knn search}
337334
issue: https://github.com/elastic/elasticsearch/issues/123727

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static TransportVersion def(int id) {
206206
public static final TransportVersion ESQL_SERIALIZE_SOURCE_FUNCTIONS_WARNINGS = def(9_016_0_00);
207207
public static final TransportVersion ESQL_DRIVER_NODE_DESCRIPTION = def(9_017_0_00);
208208
public static final TransportVersion MULTI_PROJECT = def(9_018_0_00);
209+
public static final TransportVersion STORED_SCRIPT_CONTENT_LENGTH = def(9_019_0_00);
209210

210211
/*
211212
* STOP! READ THIS FIRST! No, really,

0 commit comments

Comments
 (0)