Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-116839
Browse files Browse the repository at this point in the history
  • Loading branch information
not-napoleon authored Dec 3, 2024
2 parents df05010 + f17fc35 commit e441e4a
Show file tree
Hide file tree
Showing 100 changed files with 1,809 additions and 837 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Expand All @@ -47,6 +49,8 @@

public abstract class ElasticsearchBuildCompletePlugin implements Plugin<Project> {

private static final Logger log = LoggerFactory.getLogger(ElasticsearchBuildCompletePlugin.class);

@Inject
protected abstract FlowScope getFlowScope();

Expand Down Expand Up @@ -241,8 +245,11 @@ private static void createBuildArchiveTar(List<File> files, File projectDir, Fil
tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
tOut.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
for (Path path : files.stream().map(File::toPath).toList()) {
if (!Files.isRegularFile(path)) {
throw new IOException("Support only file!");
if (Files.exists(path) == false) {
log.warn("File disappeared before it could be added to CI archive: " + path);
continue;
} else if (!Files.isRegularFile(path)) {
throw new IOException("Support only file!: " + path);
}

long entrySize = Files.size(path);
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/117229.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 117229
summary: "In this pr, a 400 error is returned when _source / _seq_no / _feature /\
\ _nested_path / _field_names is requested, rather a 5xx"
area: Search
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/117731.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117731
summary: Add cluster level reduction
area: ES|QL
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/117842.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117842
summary: Limit size of `Literal#toString`
area: ES|QL
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/117865.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117865
summary: Fix BWC for ES|QL cluster request
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String typeName() {

@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + typeName() + "].");
throw new IllegalArgumentException("Cannot fetch values for internal field [" + typeName() + "].");
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,6 @@ tests:
- class: org.elasticsearch.search.ccs.CrossClusterIT
method: testCancel
issue: https://github.com/elastic/elasticsearch/issues/108061
- class: org.elasticsearch.xpack.ml.integration.RegressionIT
method: testTwoJobsWithSameRandomizeSeedUseSameTrainingSet
issue: https://github.com/elastic/elasticsearch/issues/117805
1 change: 1 addition & 0 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,5 @@ tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
task.skipTest("logsdb/20_source_mapping/stored _source mode is supported", "no longer serialize source_mode")
task.skipTest("logsdb/20_source_mapping/include/exclude is supported with stored _source", "no longer serialize source_mode")
task.skipTest("logsdb/20_source_mapping/synthetic _source is default", "no longer serialize source_mode")
task.skipTest("search/520_fetch_fields/fetch _seq_no via fields", "error code is changed from 5xx to 400 in 9.0")
})
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,88 @@ fetch _seq_no via stored_fields:

---
fetch _seq_no via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: "request"
catch: bad_request
search:
index: test
body:
fields: [ _seq_no ]

# This should be `unauthorized` (401) or `forbidden` (403) or at least `bad request` (400)
# while instead it is mapped to an `internal_server_error (500)`
- match: { status: 500 }
- match: { error.root_cause.0.type: unsupported_operation_exception }
- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_seq_no]: Cannot fetch values for internal field [_seq_no]." }

---
fetch _source via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _source ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_source]: Cannot fetch values for internal field [_source]." }

---
fetch _feature via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _feature ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_feature]: Cannot fetch values for internal field [_feature]." }

---
fetch _nested_path via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _nested_path ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_nested_path]: Cannot fetch values for internal field [_nested_path]." }

---
fetch _field_names via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _field_names ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_field_names]: Cannot fetch values for internal field [_field_names]." }

---
fetch fields with none stored_fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public void testScriptScore() throws ExecutionException, InterruptedException, I
for (SignificantTerms.Bucket bucket : sigTerms.getBuckets()) {
assertThat(
bucket.getSignificanceScore(),
is((double) bucket.getSubsetDf() + bucket.getSubsetSize() + bucket.getSupersetDf() + bucket.getSupersetSize())
is((double) bucket.getSubsetDf() + sigTerms.getSubsetSize() + bucket.getSupersetDf() + sigTerms.getSupersetSize())
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@
org.elasticsearch.index.codec.vectors.ES814HnswScalarQuantizedVectorsFormat,
org.elasticsearch.index.codec.vectors.ES815HnswBitVectorsFormat,
org.elasticsearch.index.codec.vectors.ES815BitFlatVectorFormat,
org.elasticsearch.index.codec.vectors.ES816BinaryQuantizedVectorsFormat,
org.elasticsearch.index.codec.vectors.ES816HnswBinaryQuantizedVectorsFormat;
org.elasticsearch.index.codec.vectors.es816.ES816BinaryQuantizedVectorsFormat,
org.elasticsearch.index.codec.vectors.es816.ES816HnswBinaryQuantizedVectorsFormat;

provides org.apache.lucene.codecs.Codec
with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.VectorScorer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.VectorUtil;
import org.elasticsearch.index.codec.vectors.BQSpaceUtils;
import org.elasticsearch.index.codec.vectors.BQVectorUtils;

import static org.apache.lucene.index.VectorSimilarityFunction.COSINE;
import static org.apache.lucene.index.VectorSimilarityFunction.EUCLIDEAN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.codecs.hnsw.FlatVectorsScorer;
import org.apache.lucene.index.VectorSimilarityFunction;
Expand All @@ -26,6 +26,8 @@
import org.apache.lucene.util.hnsw.RandomAccessVectorValues;
import org.apache.lucene.util.hnsw.RandomVectorScorer;
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
import org.elasticsearch.index.codec.vectors.BQSpaceUtils;
import org.elasticsearch.index.codec.vectors.BQVectorUtils;
import org.elasticsearch.simdvec.ESVectorUtil;

import java.io.IOException;
Expand All @@ -35,10 +37,10 @@
import static org.apache.lucene.index.VectorSimilarityFunction.MAXIMUM_INNER_PRODUCT;

/** Vector scorer over binarized vector values */
public class ES816BinaryFlatVectorsScorer implements FlatVectorsScorer {
class ES816BinaryFlatVectorsScorer implements FlatVectorsScorer {
private final FlatVectorsScorer nonQuantizedDelegate;

public ES816BinaryFlatVectorsScorer(FlatVectorsScorer nonQuantizedDelegate) {
ES816BinaryFlatVectorsScorer(FlatVectorsScorer nonQuantizedDelegate) {
this.nonQuantizedDelegate = nonQuantizedDelegate;
}

Expand Down Expand Up @@ -144,18 +146,18 @@ public RandomVectorScorerSupplier copy() throws IOException {
}

/** A binarized query representing its quantized form along with factors */
public record BinaryQueryVector(byte[] vector, BinaryQuantizer.QueryFactors factors) {}
record BinaryQueryVector(byte[] vector, BinaryQuantizer.QueryFactors factors) {}

/** Vector scorer over binarized vector values */
public static class BinarizedRandomVectorScorer extends RandomVectorScorer.AbstractRandomVectorScorer {
static class BinarizedRandomVectorScorer extends RandomVectorScorer.AbstractRandomVectorScorer {
private final BinaryQueryVector queryVector;
private final RandomAccessBinarizedByteVectorValues targetVectors;
private final VectorSimilarityFunction similarityFunction;

private final float sqrtDimensions;
private final float maxX1;

public BinarizedRandomVectorScorer(
BinarizedRandomVectorScorer(
BinaryQueryVector queryVectors,
RandomAccessBinarizedByteVectorValues targetVectors,
VectorSimilarityFunction similarityFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.codecs.hnsw.FlatVectorScorerUtil;
import org.apache.lucene.codecs.hnsw.FlatVectorsFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.codecs.hnsw.FlatVectorsReader;
Expand All @@ -42,6 +42,7 @@
import org.apache.lucene.util.SuppressForbidden;
import org.apache.lucene.util.hnsw.OrdinalTranslatedKnnCollector;
import org.apache.lucene.util.hnsw.RandomVectorScorer;
import org.elasticsearch.index.codec.vectors.BQVectorUtils;

import java.io.IOException;
import java.util.HashMap;
Expand All @@ -54,7 +55,7 @@
* Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10
*/
@SuppressForbidden(reason = "Lucene classes")
public class ES816BinaryQuantizedVectorsReader extends FlatVectorsReader {
class ES816BinaryQuantizedVectorsReader extends FlatVectorsReader {

private static final long SHALLOW_SIZE = RamUsageEstimator.shallowSizeOfInstance(ES816BinaryQuantizedVectorsReader.class);

Expand All @@ -63,7 +64,7 @@ public class ES816BinaryQuantizedVectorsReader extends FlatVectorsReader {
private final FlatVectorsReader rawVectorsReader;
private final ES816BinaryFlatVectorsScorer vectorScorer;

public ES816BinaryQuantizedVectorsReader(
ES816BinaryQuantizedVectorsReader(
SegmentReadState state,
FlatVectorsReader rawVectorsReader,
ES816BinaryFlatVectorsScorer vectorsScorer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.codecs.KnnVectorsReader;
Expand Down Expand Up @@ -48,6 +48,8 @@
import org.apache.lucene.util.hnsw.RandomVectorScorer;
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.index.codec.vectors.BQSpaceUtils;
import org.elasticsearch.index.codec.vectors.BQVectorUtils;

import java.io.Closeable;
import java.io.IOException;
Expand All @@ -61,14 +63,14 @@
import static org.apache.lucene.index.VectorSimilarityFunction.EUCLIDEAN;
import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
import static org.apache.lucene.util.RamUsageEstimator.shallowSizeOfInstance;
import static org.elasticsearch.index.codec.vectors.ES816BinaryQuantizedVectorsFormat.BINARIZED_VECTOR_COMPONENT;
import static org.elasticsearch.index.codec.vectors.ES816BinaryQuantizedVectorsFormat.DIRECT_MONOTONIC_BLOCK_SHIFT;
import static org.elasticsearch.index.codec.vectors.es816.ES816BinaryQuantizedVectorsFormat.BINARIZED_VECTOR_COMPONENT;
import static org.elasticsearch.index.codec.vectors.es816.ES816BinaryQuantizedVectorsFormat.DIRECT_MONOTONIC_BLOCK_SHIFT;

/**
* Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10
*/
@SuppressForbidden(reason = "Lucene classes")
public class ES816BinaryQuantizedVectorsWriter extends FlatVectorsWriter {
class ES816BinaryQuantizedVectorsWriter extends FlatVectorsWriter {
private static final long SHALLOW_RAM_BYTES_USED = shallowSizeOfInstance(ES816BinaryQuantizedVectorsWriter.class);

private final SegmentWriteState segmentWriteState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.codecs.KnnVectorsFormat;
import org.apache.lucene.codecs.KnnVectorsReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Modifications copyright (C) 2024 Elasticsearch B.V.
*/
package org.elasticsearch.index.codec.vectors;
package org.elasticsearch.index.codec.vectors.es816;

import org.apache.lucene.codecs.hnsw.FlatVectorsScorer;
import org.apache.lucene.codecs.lucene90.IndexedDISI;
Expand All @@ -29,6 +29,7 @@
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.hnsw.RandomVectorScorer;
import org.apache.lucene.util.packed.DirectMonotonicReader;
import org.elasticsearch.index.codec.vectors.BQVectorUtils;

import java.io.IOException;
import java.nio.ByteBuffer;
Expand All @@ -37,7 +38,7 @@
import static org.elasticsearch.index.codec.vectors.BQVectorUtils.constSqrt;

/** Binarized vector values loaded from off-heap */
public abstract class OffHeapBinarizedVectorValues extends BinarizedByteVectorValues implements RandomAccessBinarizedByteVectorValues {
abstract class OffHeapBinarizedVectorValues extends BinarizedByteVectorValues implements RandomAccessBinarizedByteVectorValues {

protected final int dimension;
protected final int size;
Expand Down Expand Up @@ -251,10 +252,10 @@ public static OffHeapBinarizedVectorValues load(
}

/** Dense off-heap binarized vector values */
public static class DenseOffHeapVectorValues extends OffHeapBinarizedVectorValues {
static class DenseOffHeapVectorValues extends OffHeapBinarizedVectorValues {
private int doc = -1;

public DenseOffHeapVectorValues(
DenseOffHeapVectorValues(
int dimension,
int size,
float[] centroid,
Expand Down
Loading

0 comments on commit e441e4a

Please sign in to comment.