Skip to content

Commit 0102e4f

Browse files
authored
Merge branch 'main' into ktlo/fix-netty-tests-with-fips
2 parents fd9c08b + aaf7b73 commit 0102e4f

File tree

9 files changed

+83
-14
lines changed

9 files changed

+83
-14
lines changed

docs/changelog/130531.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 130531
2+
summary: Adding check for `isIndexed` in text fields when generating field exists
3+
queries to avoid ISE when field is stored but not indexed or with `doc_values`
4+
area: Analysis
5+
type: bug
6+
issues: []

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ tests:
290290
- class: org.elasticsearch.packaging.test.DockerTests
291291
method: test023InstallPluginUsingConfigFile
292292
issue: https://github.com/elastic/elasticsearch/issues/126145
293-
- class: org.elasticsearch.search.SearchWithRejectionsIT
294-
method: testOpenContextsAfterRejections
295-
issue: https://github.com/elastic/elasticsearch/issues/126340
296293
- class: org.elasticsearch.smoketest.MlWithSecurityIT
297294
method: test {yaml=ml/start_data_frame_analytics/Test start classification analysis when the dependent variable cardinality is too low}
298295
issue: https://github.com/elastic/elasticsearch/issues/123200
@@ -449,9 +446,6 @@ tests:
449446
- class: org.elasticsearch.packaging.test.DockerTests
450447
method: test150MachineDependentHeap
451448
issue: https://github.com/elastic/elasticsearch/issues/128120
452-
- class: org.elasticsearch.xpack.inference.InferenceGetServicesIT
453-
method: testGetServicesWithCompletionTaskType
454-
issue: https://github.com/elastic/elasticsearch/issues/128952
455449
- class: org.elasticsearch.packaging.test.DockerTests
456450
method: test073RunEsAsDifferentUserAndGroupWithoutBindMounting
457451
issue: https://github.com/elastic/elasticsearch/issues/128996
@@ -584,9 +578,6 @@ tests:
584578
- class: org.elasticsearch.common.ssl.DefaultJdkTrustConfigTests
585579
method: testGetNonPKCS11TrustStoreWithPasswordSet
586580
issue: https://github.com/elastic/elasticsearch/issues/130519
587-
- class: org.elasticsearch.repositories.blobstore.BlobStoreCorruptionIT
588-
method: testCorruptionDetection
589-
issue: https://github.com/elastic/elasticsearch/issues/130536
590581
- class: org.elasticsearch.multiproject.test.CoreWithMultipleProjectsClientYamlTestSuiteIT
591582
method: test {yaml=indices.resolve_index/10_basic_resolve_index/Resolve index with hidden and closed indices}
592583
issue: https://github.com/elastic/elasticsearch/issues/130568

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/160_exists_query.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ setup:
4545
type: keyword
4646
text:
4747
type: text
48+
text_stored_not_indexed:
49+
type: text
50+
store: true
51+
index: false
4852

4953
- do:
5054
headers:
@@ -70,6 +74,7 @@ setup:
7074
inner1: "foo"
7175
inner2: "bar"
7276
text: "foo bar"
77+
text_stored_not_indexed: "foo bar"
7378

7479
- do:
7580
headers:
@@ -94,6 +99,7 @@ setup:
9499
object:
95100
inner1: "foo"
96101
text: "foo bar"
102+
text_stored_not_indexed: "foo bar"
97103

98104
- do:
99105
headers:
@@ -119,6 +125,7 @@ setup:
119125
object:
120126
inner2: "bar"
121127
text: "foo bar"
128+
text_stored_not_indexed: "foo bar"
122129

123130
- do:
124131
index:
@@ -184,6 +191,12 @@ setup:
184191
doc_values: false
185192
text:
186193
type: text
194+
keyword_stored_norms_not_indexed:
195+
type: keyword
196+
doc_values: false
197+
index: false
198+
store: true
199+
norms: true
187200

188201
- do:
189202
headers:
@@ -209,6 +222,7 @@ setup:
209222
inner1: "foo"
210223
inner2: "bar"
211224
text: "foo bar"
225+
keyword_stored_norms_not_indexed: "foo bar"
212226

213227
- do:
214228
headers:
@@ -233,6 +247,7 @@ setup:
233247
object:
234248
inner1: "foo"
235249
text: "foo bar"
250+
keyword_stored_norms_not_indexed: "foo bar"
236251

237252
- do:
238253
headers:
@@ -258,6 +273,7 @@ setup:
258273
object:
259274
inner2: "bar"
260275
text: "foo bar"
276+
keyword_stored_norms_not_indexed: "foo bar"
261277

262278
- do:
263279
index:
@@ -1268,3 +1284,48 @@ setup:
12681284
field: text
12691285

12701286
- match: {hits.total: 1}
1287+
1288+
---
1289+
"Test exists query on text field with no dv, that is stored but not indexed":
1290+
- requires:
1291+
capabilities:
1292+
- method: POST
1293+
path: /_search
1294+
capabilities: [ field_exists_query_for_text_fields_no_index_or_dv ]
1295+
test_runner_features: capabilities
1296+
reason: "Before the fix, this query would throw an ISE because the field is not indexed and has no doc values."
1297+
1298+
- do:
1299+
search:
1300+
rest_total_hits_as_int: true
1301+
index: test
1302+
body:
1303+
query:
1304+
exists:
1305+
field: text_stored_not_indexed
1306+
1307+
# this should not throw, but rather return 0 hits, as the field is not indexed nor it has doc values
1308+
- match: {hits.total: 0}
1309+
1310+
1311+
---
1312+
"Test exists query on keyword field with no dv, that is stored, with norms, but not indexed":
1313+
- requires:
1314+
capabilities:
1315+
- method: POST
1316+
path: /_search
1317+
capabilities: [ field_exists_query_for_text_fields_no_index_or_dv ]
1318+
test_runner_features: capabilities
1319+
reason: "Before the fix, this query would throw an ISE because the field is not indexed and has no doc values."
1320+
1321+
- do:
1322+
search:
1323+
rest_total_hits_as_int: true
1324+
index: test-no-dv
1325+
body:
1326+
query:
1327+
exists:
1328+
field: keyword_stored_norms_not_indexed
1329+
1330+
# this should not throw, but rather return 0 hits, as the field is not indexed nor it has doc values
1331+
- match: {hits.total: 0}

server/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/BlobStoreCorruptionIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void testCorruptionDetection() throws Exception {
9090
"fallback message",
9191
"org.elasticsearch.repositories.blobstore.BlobStoreRepository",
9292
Level.ERROR,
93-
"index [*] shard generation [*] in ["
93+
"index [*] shard generation [*] in [default/"
9494
+ repositoryName
9595
+ "][*] not found - falling back to reading all shard snapshots"
9696
)
@@ -100,7 +100,9 @@ public void testCorruptionDetection() throws Exception {
100100
"shard blobs list",
101101
"org.elasticsearch.repositories.blobstore.BlobStoreRepository",
102102
Level.ERROR,
103-
"read shard snapshots [*] due to missing shard generation [*] for index [*] in [" + repositoryName + "][*]"
103+
"read shard snapshots [*] due to missing shard generation [*] for index [*] in [default/"
104+
+ repositoryName
105+
+ "][*]"
104106
)
105107
);
106108
client().admin()

server/src/internalClusterTest/java/org/elasticsearch/search/SearchWithRejectionsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testOpenContextsAfterRejections() throws Exception {
5858
}
5959
assertBusy(
6060
() -> assertThat(indicesAdmin().prepareStats().get().getTotal().getSearch().getOpenContexts(), equalTo(0L)),
61-
1,
61+
2,
6262
TimeUnit.SECONDS
6363
);
6464
}

server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public Query regexpQuery(
371371
}
372372

373373
public Query existsQuery(SearchExecutionContext context) {
374-
if (hasDocValues() || getTextSearchInfo().hasNorms()) {
374+
if (hasDocValues() || (isIndexed() && getTextSearchInfo().hasNorms())) {
375375
return new FieldExistsQuery(name());
376376
} else {
377377
return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name()));

server/src/main/java/org/elasticsearch/rest/action/search/SearchCapabilities.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private SearchCapabilities() {}
5252
private static final String SIGNIFICANT_TERMS_ON_NESTED_FIELDS = "significant_terms_on_nested_fields";
5353
private static final String EXCLUDE_VECTORS_PARAM = "exclude_vectors_param";
5454
private static final String DENSE_VECTOR_UPDATABLE_BBQ = "dense_vector_updatable_bbq";
55+
private static final String FIELD_EXISTS_QUERY_FOR_TEXT_FIELDS_NO_INDEX_OR_DV = "field_exists_query_for_text_fields_no_index_or_dv";
5556

5657
public static final Set<String> CAPABILITIES;
5758
static {
@@ -75,6 +76,7 @@ private SearchCapabilities() {}
7576
capabilities.add(SIGNIFICANT_TERMS_ON_NESTED_FIELDS);
7677
capabilities.add(EXCLUDE_VECTORS_PARAM);
7778
capabilities.add(DENSE_VECTOR_UPDATABLE_BBQ);
79+
capabilities.add(FIELD_EXISTS_QUERY_FOR_TEXT_FIELDS_NO_INDEX_OR_DV);
7880
CAPABILITIES = Set.copyOf(capabilities);
7981
}
8082
}

server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldTypeTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ public void testExistsQuery() {
137137
FieldType fieldType = new FieldType();
138138
fieldType.setOmitNorms(false);
139139
KeywordFieldType ft = new KeywordFieldType("field", fieldType);
140-
assertEquals(new FieldExistsQuery("field"), ft.existsQuery(MOCK_CONTEXT));
140+
// updated in #130531 so that a field that is neither indexed nor has doc values will generate a TermQuery
141+
// to avoid ISE from FieldExistsQuery
142+
assertEquals(new TermQuery(new Term(FieldNamesFieldMapper.NAME, "field")), ft.existsQuery(MOCK_CONTEXT));
141143
}
142144
{
143145
KeywordFieldType ft = new KeywordFieldType("field", true, false, Collections.emptyMap());

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ public void testGetServicesWithRerankTaskType() throws IOException {
133133
}
134134

135135
public void testGetServicesWithCompletionTaskType() throws IOException {
136+
List<Object> services = getServices(TaskType.COMPLETION);
137+
assertThat(services.size(), equalTo(17));
138+
var providers = providers(services);
139+
136140
assertThat(
137141
providersFor(TaskType.COMPLETION),
138142
containsInAnyOrder(
@@ -146,6 +150,7 @@ public void testGetServicesWithCompletionTaskType() throws IOException {
146150
"custom",
147151
"deepseek",
148152
"googleaistudio",
153+
"googlevertexai",
149154
"openai",
150155
"streaming_completion_test_service",
151156
"completion_test_service",

0 commit comments

Comments
 (0)