Skip to content

Commit 6847428

Browse files
committed
Merge branch 'main' into files3
2 parents d99dbec + 2de1a3d commit 6847428

File tree

14 files changed

+190
-36
lines changed

14 files changed

+190
-36
lines changed

muted-tests.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ tests:
147147
issue: https://github.com/elastic/elasticsearch/issues/118914
148148
- class: org.elasticsearch.xpack.security.authc.ldap.ActiveDirectoryRunAsIT
149149
issue: https://github.com/elastic/elasticsearch/issues/115727
150-
- class: org.elasticsearch.xpack.esql.action.EsqlNodeFailureIT
151-
method: testFailureLoadingFields
152-
issue: https://github.com/elastic/elasticsearch/issues/118000
153150
- class: org.elasticsearch.index.mapper.AbstractShapeGeometryFieldMapperTests
154151
method: testCartesianBoundsBlockLoader
155152
issue: https://github.com/elastic/elasticsearch/issues/119201
@@ -305,9 +302,6 @@ tests:
305302
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
306303
method: test {yaml=reference/snapshot-restore/apis/get-snapshot-api/line_357}
307304
issue: https://github.com/elastic/elasticsearch/issues/121287
308-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
309-
method: test {p0=search.vectors/42_knn_search_int4_flat/Vector similarity with filter only}
310-
issue: https://github.com/elastic/elasticsearch/issues/115475
311305
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
312306
method: test {yaml=reference/index-modules/slowlog/line_102}
313307
issue: https://github.com/elastic/elasticsearch/issues/121288
@@ -332,12 +326,6 @@ tests:
332326
- class: org.elasticsearch.xpack.security.profile.ProfileIntegTests
333327
method: testActivateProfile
334328
issue: https://github.com/elastic/elasticsearch/issues/121151
335-
- class: org.elasticsearch.smoketest.SmokeTestMultiNodeClientYamlTestSuiteIT
336-
method: test {yaml=search.vectors/42_knn_search_int4_flat/Vector similarity with filter only}
337-
issue: https://github.com/elastic/elasticsearch/issues/121350
338-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
339-
method: test {p0=search.vectors/42_knn_search_int4_flat/KNN Vector similarity search only}
340-
issue: https://github.com/elastic/elasticsearch/issues/121395
341329
- class: org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT
342330
issue: https://github.com/elastic/elasticsearch/issues/121407
343331
- class: org.elasticsearch.xpack.ml.integration.ClassificationIT

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/42_knn_search_int4_flat.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ setup:
5757
another_vector: [-0.5, 11.0, 0, 12]
5858

5959
- do:
60-
indices.refresh: {}
60+
indices.flush: { }
6161

6262
# For added test reliability, pending the resolution of https://github.com/elastic/elasticsearch/issues/109416.
6363
- do:
@@ -66,10 +66,6 @@ setup:
6666
index: int4_flat
6767
- do:
6868
indices.refresh: {}
69-
- do:
70-
indices.forcemerge:
71-
max_num_segments: 1
72-
index: int4_flat
7369
---
7470
"kNN search only":
7571
- do:
@@ -203,13 +199,14 @@ setup:
203199
num_candidates: 3
204200
k: 3
205201
field: vector
206-
similarity: 10.3
202+
# Set high allowed similarity, reduce once we can update underlying quantization algo
203+
similarity: 110
207204
query_vector: [-0.5, 90.0, -10, 14.8]
208205

209-
- length: {hits.hits: 1}
206+
- is_true: hits.hits.0
210207

211-
- match: {hits.hits.0._id: "2"}
212-
- match: {hits.hits.0.fields.name.0: "moose.jpg"}
208+
#- match: {hits.hits.0._id: "2"}
209+
#- match: {hits.hits.0.fields.name.0: "moose.jpg"}
213210
---
214211
"Vector similarity with filter only":
215212
- do:
@@ -221,7 +218,8 @@ setup:
221218
num_candidates: 3
222219
k: 3
223220
field: vector
224-
similarity: 11
221+
# Set high allowed similarity, reduce once we can update underlying quantization algo
222+
similarity: 110
225223
query_vector: [-0.5, 90.0, -10, 14.8]
226224
filter: {"term": {"name": "moose.jpg"}}
227225

test/framework/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
api "org.elasticsearch:mocksocket:${versions.mocksocket}"
3434

3535
testImplementation project(':x-pack:plugin:mapper-unsigned-long')
36+
testImplementation project(':x-pack:plugin:mapper-counted-keyword')
3637
testImplementation project(":modules:mapper-extras")
3738
}
3839

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/FieldType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.logsdb.datageneration.datasource.DataSource;
1313
import org.elasticsearch.logsdb.datageneration.fields.leaf.ByteFieldDataGenerator;
14+
import org.elasticsearch.logsdb.datageneration.fields.leaf.CountedKeywordFieldDataGenerator;
1415
import org.elasticsearch.logsdb.datageneration.fields.leaf.DoubleFieldDataGenerator;
1516
import org.elasticsearch.logsdb.datageneration.fields.leaf.FloatFieldDataGenerator;
1617
import org.elasticsearch.logsdb.datageneration.fields.leaf.HalfFloatFieldDataGenerator;
@@ -34,7 +35,8 @@ public enum FieldType {
3435
DOUBLE("double"),
3536
FLOAT("float"),
3637
HALF_FLOAT("half_float"),
37-
SCALED_FLOAT("scaled_float");
38+
SCALED_FLOAT("scaled_float"),
39+
COUNTED_KEYWORD("counted_keyword");
3840

3941
private final String name;
4042

@@ -54,6 +56,7 @@ public FieldDataGenerator generator(String fieldName, DataSource dataSource) {
5456
case FLOAT -> new FloatFieldDataGenerator(fieldName, dataSource);
5557
case HALF_FLOAT -> new HalfFloatFieldDataGenerator(fieldName, dataSource);
5658
case SCALED_FLOAT -> new ScaledFloatFieldDataGenerator(fieldName, dataSource);
59+
case COUNTED_KEYWORD -> new CountedKeywordFieldDataGenerator(fieldName, dataSource);
5760
};
5861
}
5962

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DataSourceHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ default DataSourceResponse.ArrayWrapper handle(DataSourceRequest.ArrayWrapper re
5454
return null;
5555
}
5656

57+
default DataSourceResponse.RepeatingWrapper handle(DataSourceRequest.RepeatingWrapper request) {
58+
return null;
59+
}
60+
5761
default DataSourceResponse.ChildFieldGenerator handle(DataSourceRequest.ChildFieldGenerator request) {
5862
return null;
5963
}

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DataSourceRequest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public DataSourceResponse.ArrayWrapper accept(DataSourceHandler handler) {
8585
}
8686
}
8787

88+
record RepeatingWrapper() implements DataSourceRequest<DataSourceResponse.RepeatingWrapper> {
89+
public DataSourceResponse.RepeatingWrapper accept(DataSourceHandler handler) {
90+
return handler.handle(this);
91+
}
92+
}
93+
8894
record ChildFieldGenerator(DataGeneratorSpecification specification)
8995
implements
9096
DataSourceRequest<DataSourceResponse.ChildFieldGenerator> {

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DataSourceResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ record NullWrapper(Function<Supplier<Object>, Supplier<Object>> wrapper) impleme
3939

4040
record ArrayWrapper(Function<Supplier<Object>, Supplier<Object>> wrapper) implements DataSourceResponse {}
4141

42+
record RepeatingWrapper(Function<Supplier<Object>, Supplier<Object>> wrapper) implements DataSourceResponse {}
43+
4244
interface ChildFieldGenerator extends DataSourceResponse {
4345
int generateChildFieldCount();
4446

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DefaultMappingParametersHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public DataSourceResponse.LeafMappingParametersGenerator handle(DataSourceReques
3333
case KEYWORD -> keywordMapping(request, map);
3434
case LONG, INTEGER, SHORT, BYTE, DOUBLE, FLOAT, HALF_FLOAT, UNSIGNED_LONG -> plain(map);
3535
case SCALED_FLOAT -> scaledFloatMapping(map);
36+
case COUNTED_KEYWORD -> plain(Map.of("index", ESTestCase.randomBoolean()));
3637
});
3738
}
3839

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DefaultWrappersHandler.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.test.ESTestCase;
1313

14+
import java.util.HashSet;
1415
import java.util.function.Function;
1516
import java.util.function.Supplier;
1617
import java.util.stream.IntStream;
@@ -26,6 +27,11 @@ public DataSourceResponse.ArrayWrapper handle(DataSourceRequest.ArrayWrapper ign
2627
return new DataSourceResponse.ArrayWrapper(wrapInArray());
2728
}
2829

30+
@Override
31+
public DataSourceResponse.RepeatingWrapper handle(DataSourceRequest.RepeatingWrapper ignored) {
32+
return new DataSourceResponse.RepeatingWrapper(repeatValues());
33+
}
34+
2935
private static Function<Supplier<Object>, Supplier<Object>> injectNulls() {
3036
// Inject some nulls but majority of data should be non-null (as it likely is in reality).
3137
return (values) -> () -> ESTestCase.randomDouble() <= 0.05 ? null : values.get();
@@ -41,4 +47,19 @@ private static Function<Supplier<Object>, Supplier<Object>> wrapInArray() {
4147
return values.get();
4248
};
4349
}
50+
51+
private static Function<Supplier<Object>, Supplier<Object>> repeatValues() {
52+
return (values) -> {
53+
HashSet<Object> previousValues = new HashSet<>();
54+
return () -> {
55+
if (previousValues.size() > 0 && ESTestCase.randomBoolean()) {
56+
return ESTestCase.randomFrom(previousValues);
57+
} else {
58+
var value = values.get();
59+
previousValues.add(value);
60+
return value;
61+
}
62+
};
63+
};
64+
}
4465
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.logsdb.datageneration.fields.leaf;
11+
12+
import org.elasticsearch.logsdb.datageneration.FieldDataGenerator;
13+
import org.elasticsearch.logsdb.datageneration.datasource.DataSource;
14+
import org.elasticsearch.logsdb.datageneration.datasource.DataSourceRequest;
15+
16+
import java.util.HashSet;
17+
import java.util.Set;
18+
import java.util.function.Supplier;
19+
20+
public class CountedKeywordFieldDataGenerator implements FieldDataGenerator {
21+
private final Supplier<Object> valueGenerator;
22+
private final Set<String> previousStrings = new HashSet<>();
23+
24+
public CountedKeywordFieldDataGenerator(String fieldName, DataSource dataSource) {
25+
var strings = dataSource.get(new DataSourceRequest.StringGenerator());
26+
var nulls = dataSource.get(new DataSourceRequest.NullWrapper());
27+
var arrays = dataSource.get(new DataSourceRequest.ArrayWrapper());
28+
var repeats = dataSource.get(new DataSourceRequest.RepeatingWrapper());
29+
30+
this.valueGenerator = arrays.wrapper().compose(nulls.wrapper().compose(repeats.wrapper())).apply(() -> strings.generator().get());
31+
}
32+
33+
@Override
34+
public Object generateValue() {
35+
return valueGenerator.get();
36+
}
37+
}

0 commit comments

Comments
 (0)