Skip to content

Commit f2e8730

Browse files
committed
Merge branch 'main' into add-bwcLucene87Codec
2 parents dce64b2 + 6260746 commit f2e8730

File tree

54 files changed

+436
-97
lines changed

Some content is hidden

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

54 files changed

+436
-97
lines changed

.buildkite/scripts/dra-workflow.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ find "$WORKSPACE" -type d -path "*/build/distributions" -exec chmod a+w {} \;
7575

7676
echo --- Running release-manager
7777

78+
set +e
7879
# Artifacts should be generated
7980
docker run --rm \
8081
--name release-manager \
@@ -91,4 +92,16 @@ docker run --rm \
9192
--version "$ES_VERSION" \
9293
--artifact-set main \
9394
--dependency "beats:https://artifacts-${WORKFLOW}.elastic.co/beats/${BEATS_BUILD_ID}/manifest-${ES_VERSION}${VERSION_SUFFIX}.json" \
94-
--dependency "ml-cpp:https://artifacts-${WORKFLOW}.elastic.co/ml-cpp/${ML_CPP_BUILD_ID}/manifest-${ES_VERSION}${VERSION_SUFFIX}.json"
95+
--dependency "ml-cpp:https://artifacts-${WORKFLOW}.elastic.co/ml-cpp/${ML_CPP_BUILD_ID}/manifest-${ES_VERSION}${VERSION_SUFFIX}.json" \
96+
2>&1 | tee release-manager.log
97+
EXIT_CODE=$?
98+
set -e
99+
100+
# This failure is just generating a ton of noise right now, so let's just ignore it
101+
# This should be removed once this issue has been fixed
102+
if grep "elasticsearch-ubi-9.0.0-SNAPSHOT-docker-image.tar.gz" release-manager.log; then
103+
echo "Ignoring error about missing ubi artifact"
104+
exit 0
105+
fi
106+
107+
exit "$EXIT_CODE"

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum DockerBase {
2222
// Chainguard based wolfi image with latest jdk
2323
// This is usually updated via renovatebot
2424
// spotless:off
25-
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:973431347ad45f40e01afbbd010bf9de929c088a63382239b90dd84f39618bc8",
25+
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:55b297da5151d2a2997e8ab9729fe1304e4869389d7090ab7031cc29530f69f8",
2626
"-wolfi",
2727
"apk"
2828
),

docs/changelog/117404.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 117404
2+
summary: Correct bit * byte and bit * float script comparisons
3+
area: Vector Search
4+
type: bug
5+
issues: []

docs/reference/vectors/vector-functions.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ When using `bit` vectors, not all the vector functions are available. The suppor
336336
this is the sum of the bitwise AND of the two vectors. If providing `float[]` or `byte[]`, who has `dims` number of elements, as a query vector, the `dotProduct` is
337337
the sum of the floating point values using the stored `bit` vector as a mask.
338338

339+
NOTE: When comparing `floats` and `bytes` with `bit` vectors, the `bit` vector is treated as a mask in big-endian order.
340+
For example, if the `bit` vector is `10100001` (e.g. the single byte value `161`) and its compared
341+
with array of values `[1, 2, 3, 4, 5, 6, 7, 8]` the `dotProduct` will be `1 + 3 + 8 = 16`.
342+
339343
Here is an example of using dot-product with bit vectors.
340344

341345
[source,console]

libs/simdvec/src/main/java/org/elasticsearch/simdvec/ESVectorUtil.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public static long ipByteBinByte(byte[] q, byte[] d) {
5151
/**
5252
* Compute the inner product of two vectors, where the query vector is a byte vector and the document vector is a bit vector.
5353
* This will return the sum of the query vector values using the document vector as a mask.
54+
* When comparing the bits with the bytes, they are done in "big endian" order. For example, if the byte vector
55+
* is [1, 2, 3, 4, 5, 6, 7, 8] and the bit vector is [0b10000000], the inner product will be 1.0.
5456
* @param q the query vector
5557
* @param d the document vector
5658
* @return the inner product of the two vectors
@@ -63,9 +65,9 @@ public static int ipByteBit(byte[] q, byte[] d) {
6365
// now combine the two vectors, summing the byte dimensions where the bit in d is `1`
6466
for (int i = 0; i < d.length; i++) {
6567
byte mask = d[i];
66-
for (int j = 0; j < Byte.SIZE; j++) {
68+
for (int j = Byte.SIZE - 1; j >= 0; j--) {
6769
if ((mask & (1 << j)) != 0) {
68-
result += q[i * Byte.SIZE + j];
70+
result += q[i * Byte.SIZE + Byte.SIZE - 1 - j];
6971
}
7072
}
7173
}
@@ -75,6 +77,8 @@ public static int ipByteBit(byte[] q, byte[] d) {
7577
/**
7678
* Compute the inner product of two vectors, where the query vector is a float vector and the document vector is a bit vector.
7779
* This will return the sum of the query vector values using the document vector as a mask.
80+
* When comparing the bits with the floats, they are done in "big endian" order. For example, if the float vector
81+
* is [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] and the bit vector is [0b10000000], the inner product will be 1.0.
7882
* @param q the query vector
7983
* @param d the document vector
8084
* @return the inner product of the two vectors
@@ -86,9 +90,9 @@ public static float ipFloatBit(float[] q, byte[] d) {
8690
float result = 0;
8791
for (int i = 0; i < d.length; i++) {
8892
byte mask = d[i];
89-
for (int j = 0; j < Byte.SIZE; j++) {
93+
for (int j = Byte.SIZE - 1; j >= 0; j--) {
9094
if ((mask & (1 << j)) != 0) {
91-
result += q[i * Byte.SIZE + j];
95+
result += q[i * Byte.SIZE + Byte.SIZE - 1 - j];
9296
}
9397
}
9498
}

libs/simdvec/src/test/java/org/elasticsearch/simdvec/ESVectorUtilTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ public class ESVectorUtilTests extends BaseVectorizationTests {
2121
static final ESVectorizationProvider defaultedProvider = BaseVectorizationTests.defaultProvider();
2222
static final ESVectorizationProvider defOrPanamaProvider = BaseVectorizationTests.maybePanamaProvider();
2323

24+
public void testIpByteBit() {
25+
byte[] q = new byte[16];
26+
byte[] d = new byte[] { (byte) Integer.parseInt("01100010", 2), (byte) Integer.parseInt("10100111", 2) };
27+
random().nextBytes(q);
28+
int expected = q[1] + q[2] + q[6] + q[8] + q[10] + q[13] + q[14] + q[15];
29+
assertEquals(expected, ESVectorUtil.ipByteBit(q, d));
30+
}
31+
32+
public void testIpFloatBit() {
33+
float[] q = new float[16];
34+
byte[] d = new byte[] { (byte) Integer.parseInt("01100010", 2), (byte) Integer.parseInt("10100111", 2) };
35+
random().nextFloat();
36+
float expected = q[1] + q[2] + q[6] + q[8] + q[10] + q[13] + q[14] + q[15];
37+
assertEquals(expected, ESVectorUtil.ipFloatBit(q, d), 1e-6);
38+
}
39+
2440
public void testBitAndCount() {
2541
testBasicBitAndImpl(ESVectorUtil::andBitCountLong);
2642
}

modules/data-streams/src/test/java/org/elasticsearch/datastreams/mapper/DataStreamTimestampFieldMapperTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ protected void registerParameters(ParameterChecker checker) throws IOException {
4848
checker.registerConflictCheck(
4949
"enabled",
5050
timestampMapping(true, b -> b.startObject("@timestamp").field("type", "date").endObject()),
51-
timestampMapping(false, b -> b.startObject("@timestamp").field("type", "date").endObject())
51+
timestampMapping(false, b -> b.startObject("@timestamp").field("type", "date").endObject()),
52+
dm -> {}
5253
);
5354
checker.registerUpdateCheck(
5455
timestampMapping(false, b -> b.startObject("@timestamp").field("type", "date").endObject()),

modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/141_multi_dense_vector_max_sim.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ setup:
33
capabilities:
44
- method: POST
55
path: /_search
6-
capabilities: [ multi_dense_vector_script_max_sim ]
6+
capabilities: [ multi_dense_vector_script_max_sim_with_bugfix ]
77
test_runner_features: capabilities
88
reason: "Support for multi dense vector max-sim functions capability required"
99
- skip:
@@ -136,10 +136,10 @@ setup:
136136
- match: {hits.total: 2}
137137

138138
- match: {hits.hits.0._id: "1"}
139-
- close_to: {hits.hits.0._score: {value: 190, error: 0.01}}
139+
- close_to: {hits.hits.0._score: {value: 220, error: 0.01}}
140140

141141
- match: {hits.hits.1._id: "3"}
142-
- close_to: {hits.hits.1._score: {value: 125, error: 0.01}}
142+
- close_to: {hits.hits.1._score: {value: 147, error: 0.01}}
143143
---
144144
"Test max-sim inv hamming scoring":
145145
- skip:

modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/146_dense_vector_bit_basic.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ setup:
108108
capabilities:
109109
- method: POST
110110
path: /_search
111-
capabilities: [ byte_float_bit_dot_product ]
111+
capabilities: [ byte_float_bit_dot_product_with_bugfix ]
112112
reason: Capability required to run test
113113
- do:
114114
catch: bad_request
@@ -399,7 +399,7 @@ setup:
399399
capabilities:
400400
- method: POST
401401
path: /_search
402-
capabilities: [ byte_float_bit_dot_product ]
402+
capabilities: [ byte_float_bit_dot_product_with_bugfix ]
403403
test_runner_features: [capabilities, close_to]
404404
reason: Capability required to run test
405405
- do:
@@ -419,13 +419,13 @@ setup:
419419
- match: { hits.total: 3 }
420420

421421
- match: {hits.hits.0._id: "2"}
422-
- close_to: {hits.hits.0._score: {value: 35.999, error: 0.01}}
422+
- close_to: {hits.hits.0._score: {value: 33.78, error: 0.01}}
423423

424424
- match: {hits.hits.1._id: "3"}
425-
- close_to: {hits.hits.1._score:{value: 27.23, error: 0.01}}
425+
- close_to: {hits.hits.1._score:{value: 22.579, error: 0.01}}
426426

427427
- match: {hits.hits.2._id: "1"}
428-
- close_to: {hits.hits.2._score: {value: 16.57, error: 0.01}}
428+
- close_to: {hits.hits.2._score: {value: 11.919, error: 0.01}}
429429

430430
- do:
431431
headers:
@@ -444,20 +444,20 @@ setup:
444444
- match: { hits.total: 3 }
445445

446446
- match: {hits.hits.0._id: "2"}
447-
- close_to: {hits.hits.0._score: {value: 35.999, error: 0.01}}
447+
- close_to: {hits.hits.0._score: {value: 33.78, error: 0.01}}
448448

449449
- match: {hits.hits.1._id: "3"}
450-
- close_to: {hits.hits.1._score:{value: 27.23, error: 0.01}}
450+
- close_to: {hits.hits.1._score:{value: 22.579, error: 0.01}}
451451

452452
- match: {hits.hits.2._id: "1"}
453-
- close_to: {hits.hits.2._score: {value: 16.57, error: 0.01}}
453+
- close_to: {hits.hits.2._score: {value: 11.919, error: 0.01}}
454454
---
455455
"Dot product with byte":
456456
- requires:
457457
capabilities:
458458
- method: POST
459459
path: /_search
460-
capabilities: [ byte_float_bit_dot_product ]
460+
capabilities: [ byte_float_bit_dot_product_with_bugfix ]
461461
test_runner_features: capabilities
462462
reason: Capability required to run test
463463
- do:
@@ -476,14 +476,14 @@ setup:
476476

477477
- match: { hits.total: 3 }
478478

479-
- match: {hits.hits.0._id: "1"}
480-
- match: {hits.hits.0._score: 248}
479+
- match: {hits.hits.0._id: "3"}
480+
- match: {hits.hits.0._score: 415}
481481

482-
- match: {hits.hits.1._id: "2"}
483-
- match: {hits.hits.1._score: 136}
482+
- match: {hits.hits.1._id: "1"}
483+
- match: {hits.hits.1._score: 168}
484484

485-
- match: {hits.hits.2._id: "3"}
486-
- match: {hits.hits.2._score: 20}
485+
- match: {hits.hits.2._id: "2"}
486+
- match: {hits.hits.2._score: 126}
487487

488488
- do:
489489
headers:
@@ -501,11 +501,11 @@ setup:
501501

502502
- match: { hits.total: 3 }
503503

504-
- match: {hits.hits.0._id: "1"}
505-
- match: {hits.hits.0._score: 248}
504+
- match: {hits.hits.0._id: "3"}
505+
- match: {hits.hits.0._score: 415}
506506

507-
- match: {hits.hits.1._id: "2"}
508-
- match: {hits.hits.1._score: 136}
507+
- match: {hits.hits.1._id: "1"}
508+
- match: {hits.hits.1._score: 168}
509509

510-
- match: {hits.hits.2._id: "3"}
511-
- match: {hits.hits.2._score: 20}
510+
- match: {hits.hits.2._id: "2"}
511+
- match: {hits.hits.2._score: 126}

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.netty.handler.timeout.ReadTimeoutException;
3434
import io.netty.handler.timeout.ReadTimeoutHandler;
3535
import io.netty.util.AttributeKey;
36+
import io.netty.util.ResourceLeakDetector;
3637

3738
import org.apache.logging.log4j.LogManager;
3839
import org.apache.logging.log4j.Logger;
@@ -410,6 +411,9 @@ protected Result beginEncode(HttpResponse httpResponse, String acceptEncoding) t
410411
}
411412
});
412413
}
414+
if (ResourceLeakDetector.isEnabled()) {
415+
ch.pipeline().addLast(new Netty4LeakDetectionHandler());
416+
}
413417
ch.pipeline()
414418
.addLast(
415419
"pipelining",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.http.netty4;
11+
12+
import io.netty.channel.ChannelHandlerContext;
13+
import io.netty.channel.ChannelInboundHandlerAdapter;
14+
import io.netty.handler.codec.http.HttpContent;
15+
import io.netty.handler.codec.http.HttpRequest;
16+
17+
import org.elasticsearch.tasks.Task;
18+
19+
/**
20+
* Inbound channel handler that enrich leaking buffers information from HTTP request.
21+
* It helps to detect which handler is leaking buffers. Especially integration tests that run with
22+
* paranoid leak detector that samples all buffers for leaking. Supplying informative opaque-id in
23+
* integ test helps to narrow down problem (for example test name).
24+
*/
25+
public class Netty4LeakDetectionHandler extends ChannelInboundHandlerAdapter {
26+
27+
private String info;
28+
29+
@Override
30+
public void channelRead(ChannelHandlerContext ctx, Object msg) {
31+
if (msg instanceof HttpRequest request) {
32+
var opaqueId = request.headers().get(Task.X_OPAQUE_ID_HTTP_HEADER);
33+
info = "method: " + request.method() + "; uri: " + request.uri() + "; x-opaque-id: " + opaqueId;
34+
}
35+
if (msg instanceof HttpContent content) {
36+
content.touch(info);
37+
}
38+
ctx.fireChannelRead(msg);
39+
}
40+
}

muted-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ tests:
185185
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
186186
method: test {p0=snapshot/20_operator_privileges_disabled/Operator only settings can be set and restored by non-operator user when operator privileges is disabled}
187187
issue: https://github.com/elastic/elasticsearch/issues/116775
188-
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
189-
method: test {p0=synonyms/90_synonyms_reloading_for_synset/Reload analyzers for specific synonym set}
190-
issue: https://github.com/elastic/elasticsearch/issues/116777
191188
- class: org.elasticsearch.xpack.searchablesnapshots.hdfs.SecureHdfsSearchableSnapshotsIT
192189
issue: https://github.com/elastic/elasticsearch/issues/116851
193190
- class: org.elasticsearch.search.basic.SearchWithRandomIOExceptionsIT
@@ -235,6 +232,12 @@ tests:
235232
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
236233
method: test {p0=transform/transforms_reset/Test reset running transform}
237234
issue: https://github.com/elastic/elasticsearch/issues/117473
235+
- class: org.elasticsearch.xpack.esql.qa.single_node.FieldExtractorIT
236+
method: testConstantKeywordField
237+
issue: https://github.com/elastic/elasticsearch/issues/117524
238+
- class: org.elasticsearch.xpack.esql.qa.multi_node.FieldExtractorIT
239+
method: testConstantKeywordField
240+
issue: https://github.com/elastic/elasticsearch/issues/117524
238241

239242
# Examples:
240243
#

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.common.xcontent.support.XContentMapValues;
2121
import org.elasticsearch.core.UpdateForV9;
2222
import org.elasticsearch.index.mapper.DateFieldMapper;
23+
import org.elasticsearch.index.mapper.SourceFieldMapper;
2324
import org.elasticsearch.index.mapper.TimeSeriesIdFieldMapper;
2425
import org.elasticsearch.test.ListMatcher;
2526
import org.elasticsearch.xcontent.XContentBuilder;
@@ -417,9 +418,15 @@ public void testSyntheticSource() throws IOException {
417418
if (isOldCluster()) {
418419
Request createIndex = new Request("PUT", "/synthetic");
419420
XContentBuilder indexSpec = XContentBuilder.builder(XContentType.JSON.xContent()).startObject();
421+
boolean useIndexSetting = SourceFieldMapper.onOrAfterDeprecateModeVersion(getOldClusterIndexVersion());
422+
if (useIndexSetting) {
423+
indexSpec.startObject("settings").field("index.mapping.source.mode", "synthetic").endObject();
424+
}
420425
indexSpec.startObject("mappings");
421426
{
422-
indexSpec.startObject("_source").field("mode", "synthetic").endObject();
427+
if (useIndexSetting == false) {
428+
indexSpec.startObject("_source").field("mode", "synthetic").endObject();
429+
}
423430
indexSpec.startObject("properties").startObject("kwd").field("type", "keyword").endObject().endObject();
424431
}
425432
indexSpec.endObject();

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/10_synonyms_put.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ setup:
1717

1818
- do:
1919
cluster.health:
20-
wait_for_no_initializing_shards: true
20+
index: .synonyms-2
21+
timeout: 2s
22+
wait_for_status: green
23+
ignore: 408
2124

2225
- do:
2326
synonyms.get_synonym:
@@ -64,7 +67,10 @@ setup:
6467

6568
- do:
6669
cluster.health:
67-
wait_for_no_initializing_shards: true
70+
index: .synonyms-2
71+
timeout: 2s
72+
wait_for_status: green
73+
ignore: 408
6874

6975
- do:
7076
synonyms.get_synonym:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/110_synonyms_invalid.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ setup:
1414
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
1515
- do:
1616
cluster.health:
17-
wait_for_no_initializing_shards: true
17+
index: .synonyms-2
18+
timeout: 2s
19+
wait_for_status: green
20+
ignore: 408
1821

1922
- do:
2023
indices.create:

0 commit comments

Comments
 (0)