Skip to content

Commit a4c9383

Browse files
authored
Merge branch '9.1' into backport/9.1/pr-137456
2 parents bfedf8f + 854c520 commit a4c9383

File tree

64 files changed

+1415
-206
lines changed

Some content is hidden

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

64 files changed

+1415
-206
lines changed

build-tools-internal/version.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ commons_lang3 = 3.9
1919
google_oauth_client = 1.34.1
2020
awsv2sdk = 2.31.78
2121
reactive_streams = 1.0.4
22+
ldapsdk = 7.0.3
2223

2324
antlr4 = 4.13.1
2425
# bouncy castle version for non-fips. fips jars use a different version

distribution/docker/src/docker/dockerfiles/cloud_ess_fips/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Extract Elasticsearch artifact
2626
################################################################################
2727
28-
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:4d8871dbc3525d92a71b1f76145d4d9101d01951e9500040f30f16ac73bf36d8 AS builder
28+
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:a02c67d96cd6ec1b50a055f1f5515e0987b643d001d436088cefc02e5b786bf9 AS builder
2929
3030
# Install required packages to extract the Elasticsearch distribution
3131
RUN <%= retry.loop(package_manager, "export DEBIAN_FRONTEND=noninteractive && ${package_manager} update && ${package_manager} update && ${package_manager} add --no-cache curl") %>
@@ -104,7 +104,7 @@ WORKDIR /usr/share/elasticsearch/config
104104
# Add entrypoint
105105
################################################################################
106106

107-
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:4d8871dbc3525d92a71b1f76145d4d9101d01951e9500040f30f16ac73bf36d8
107+
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:a02c67d96cd6ec1b50a055f1f5515e0987b643d001d436088cefc02e5b786bf9
108108

109109
RUN <%= retry.loop(package_manager,
110110
"export DEBIAN_FRONTEND=noninteractive && \n" +

distribution/docker/src/docker/dockerfiles/wolfi/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Extract Elasticsearch artifact
2626
################################################################################
2727
28-
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:4f225dcff81c518939e79180749b55b60287b2edbce40801834380e285ca9076 AS builder
28+
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:25397820ef168d951339e69cedb5460f354cea842e2af367e33b89e988c51615 AS builder
2929
3030
# Install required packages to extract the Elasticsearch distribution
3131
RUN <%= retry.loop(package_manager, "export DEBIAN_FRONTEND=noninteractive && ${package_manager} update && ${package_manager} update && ${package_manager} add --no-cache curl") %>
@@ -80,7 +80,7 @@ RUN sed -i -e 's/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' bin/elas
8080
# Add entrypoint
8181
################################################################################
8282

83-
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:4f225dcff81c518939e79180749b55b60287b2edbce40801834380e285ca9076
83+
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:25397820ef168d951339e69cedb5460f354cea842e2af367e33b89e988c51615
8484

8585
RUN <%= retry.loop(package_manager,
8686
"export DEBIAN_FRONTEND=noninteractive && \n" +

docs/changelog/137862.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 137862
2+
summary: "[Vector Search] Fix wrong vector docvalue_fields"
3+
area: Vector Search
4+
type: bug
5+
issues: []

docs/changelog/138053.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 138053
2+
summary: Upgrade UnboundID LDAP SDK to 7.0.3
3+
area: Security
4+
type: upgrade
5+
issues: []

docs/changelog/138097.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 138097
2+
summary: Bump anomalies index template version to install latest
3+
area: Machine Learning
4+
type: bug
5+
issues: []

docs/changelog/138308.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 138308
2+
summary: Reject mappings that (eventually) set dimension and metric in the same field
3+
area: Mapping
4+
type: bug
5+
issues: []

gradle/verification-metadata.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,9 +1312,9 @@
13121312
<sha256 value="6eb0f1cecc687655f8d9c167073f4c2eda4805040d03f982d4d127a141bde375" origin="Generated by Gradle"/>
13131313
</artifact>
13141314
</component>
1315-
<component group="com.unboundid" name="unboundid-ldapsdk" version="6.0.3">
1316-
<artifact name="unboundid-ldapsdk-6.0.3.jar">
1317-
<sha256 value="a635f130b482d8b02cc317632de762518d6bfedfecbd6972d1029124aaaf89d8" origin="Generated by Gradle"/>
1315+
<component group="com.unboundid" name="unboundid-ldapsdk" version="7.0.3">
1316+
<artifact name="unboundid-ldapsdk-7.0.3.jar">
1317+
<sha256 value="7f1b9141f2c955d3a03b3f5da2c450bd616826e921a87fc19264a3f22b35e2fb" origin="Generated by Gradle"/>
13181318
</artifact>
13191319
</component>
13201320
<component group="com.vaadin.external.google" name="android-json" version="0.0.20131108.vaadin1">

modules/percolator/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
requires org.apache.lucene.memory;
1717
requires org.apache.lucene.queries;
1818
requires org.apache.lucene.sandbox;
19+
requires org.elasticsearch.logging;
1920
}

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.elasticsearch.TransportVersion;
3838
import org.elasticsearch.TransportVersions;
3939
import org.elasticsearch.action.get.GetRequest;
40+
import org.elasticsearch.common.CheckedSupplier;
4041
import org.elasticsearch.common.bytes.BytesReference;
4142
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
4243
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
@@ -63,6 +64,10 @@
6364
import org.elasticsearch.index.query.SearchExecutionContext;
6465
import org.elasticsearch.indices.breaker.CircuitBreakerService;
6566
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
67+
import org.elasticsearch.logging.LogManager;
68+
import org.elasticsearch.logging.Logger;
69+
import org.elasticsearch.search.lookup.Source;
70+
import org.elasticsearch.search.lookup.SourceProvider;
6671
import org.elasticsearch.xcontent.ConstructingObjectParser;
6772
import org.elasticsearch.xcontent.NamedXContentRegistry;
6873
import org.elasticsearch.xcontent.ParseField;
@@ -86,6 +91,8 @@
8691
import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg;
8792

8893
public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBuilder> {
94+
private static final Logger LOGGER = LogManager.getLogger(PercolateQueryBuilder.class);
95+
8996
public static final String NAME = "percolate";
9097

9198
static final ParseField DOCUMENT_FIELD = new ParseField("document");
@@ -557,41 +564,81 @@ static PercolateQuery.QueryStore createStore(MappedFieldType queryBuilderFieldTy
557564
return docId -> {
558565
if (binaryDocValues.advanceExact(docId)) {
559566
BytesRef qbSource = binaryDocValues.binaryValue();
560-
try (
561-
InputStream in = new ByteArrayInputStream(qbSource.bytes, qbSource.offset, qbSource.length);
562-
StreamInput input = new NamedWriteableAwareStreamInput(new InputStreamStreamInput(in, qbSource.length), registry)
563-
) {
564-
// Query builder's content is stored via BinaryFieldMapper, which has a custom encoding
565-
// to encode multiple binary values into a single binary doc values field.
566-
// This is the reason we need to first read the number of values and
567-
// then the length of the field value in bytes.
568-
int numValues = input.readVInt();
569-
assert numValues == 1;
570-
int valueLength = input.readVInt();
571-
assert valueLength > 0;
572-
573-
TransportVersion transportVersion;
574-
if (indexVersion.before(IndexVersions.V_8_8_0)) {
575-
transportVersion = TransportVersion.fromId(indexVersion.id());
576-
} else {
577-
transportVersion = TransportVersion.readVersion(input);
567+
QueryBuilder queryBuilder = readQueryBuilder(qbSource, registry, indexVersion, () -> {
568+
// query builder is written in an incompatible format, fall-back to reading it from source
569+
if (context.isSourceEnabled() == false) {
570+
throw new ElasticsearchException(
571+
"Unable to read percolator query. Original transport version is incompatible and source is "
572+
+ "unavailable on index [{}].",
573+
context.index().getName()
574+
);
578575
}
579-
// set the transportversion here - only read vints so far, so can change the version freely at this point
580-
input.setTransportVersion(transportVersion);
581-
582-
QueryBuilder queryBuilder = input.readNamedWriteable(QueryBuilder.class);
583-
assert in.read() == -1;
584-
queryBuilder = Rewriteable.rewrite(queryBuilder, context);
585-
return queryBuilder.toQuery(context);
586-
}
587-
576+
LOGGER.warn(
577+
"Reading percolator query from source. For best performance, reindexing of index [{}] is required.",
578+
context.index().getName()
579+
);
580+
SourceProvider sourceProvider = context.createSourceProvider();
581+
Source source = sourceProvider.getSource(ctx, docId);
582+
SourceToParse sourceToParse = new SourceToParse(
583+
String.valueOf(docId),
584+
source.internalSourceRef(),
585+
source.sourceContentType()
586+
);
587+
588+
return context.parseDocument(sourceToParse).rootDoc().getBinaryValue(queryBuilderFieldType.name());
589+
});
590+
591+
queryBuilder = Rewriteable.rewrite(queryBuilder, context);
592+
return queryBuilder.toQuery(context);
588593
} else {
589594
return null;
590595
}
591596
};
592597
};
593598
}
594599

600+
private static QueryBuilder readQueryBuilder(
601+
BytesRef bytesRef,
602+
NamedWriteableRegistry registry,
603+
IndexVersion indexVersion,
604+
CheckedSupplier<BytesRef, IOException> fallbackSource
605+
) throws IOException {
606+
try (
607+
InputStream in = new ByteArrayInputStream(bytesRef.bytes, bytesRef.offset, bytesRef.length);
608+
StreamInput input = new NamedWriteableAwareStreamInput(new InputStreamStreamInput(in, bytesRef.length), registry)
609+
) {
610+
// Query builder's content is stored via BinaryFieldMapper, which has a custom encoding
611+
// to encode multiple binary values into a single binary doc values field.
612+
// This is the reason we need to first read the number of values and
613+
// then the length of the field value in bytes.
614+
int numValues = input.readVInt();
615+
assert numValues == 1;
616+
int valueLength = input.readVInt();
617+
assert valueLength > 0;
618+
619+
TransportVersion transportVersion;
620+
if (indexVersion.before(IndexVersions.V_8_8_0)) {
621+
transportVersion = TransportVersion.fromId(indexVersion.id());
622+
} else {
623+
transportVersion = TransportVersion.readVersion(input);
624+
}
625+
626+
QueryBuilder queryBuilder;
627+
628+
if (TransportVersion.isCompatible(transportVersion) || fallbackSource == null) {
629+
// set the transportversion here - only read vints so far, so can change the version freely at this point
630+
input.setTransportVersion(transportVersion);
631+
queryBuilder = input.readNamedWriteable(QueryBuilder.class);
632+
assert in.read() == -1;
633+
} else {
634+
// incompatible transport version, try the fallback
635+
queryBuilder = readQueryBuilder(fallbackSource.get(), registry, indexVersion, null);
636+
}
637+
638+
return queryBuilder;
639+
}
640+
}
641+
595642
static SearchExecutionContext wrap(SearchExecutionContext delegate) {
596643
return new SearchExecutionContext(delegate) {
597644

0 commit comments

Comments
 (0)