Skip to content

Commit 46fcaa9

Browse files
authored
Merge branch 'main' into elastic-provider-rerank-integration
2 parents 9fb2aa8 + 04848b1 commit 46fcaa9

File tree

13 files changed

+516
-102
lines changed

13 files changed

+516
-102
lines changed

docs/changelog/128702.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128702
2+
summary: Fix missing highlighting in `match_all` queries for `semantic_text` fields
3+
area: Search
4+
type: bug
5+
issues: []

muted-tests.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -507,18 +507,6 @@ tests:
507507
- class: org.elasticsearch.index.store.DirectIOIT
508508
method: testDirectIOUsed
509509
issue: https://github.com/elastic/elasticsearch/issues/128829
510-
- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT
511-
method: test {p0=esql/190_lookup_join/alias-repeated-index}
512-
issue: https://github.com/elastic/elasticsearch/issues/128849
513-
- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT
514-
method: test {p0=esql/190_lookup_join/alias-repeated-alias}
515-
issue: https://github.com/elastic/elasticsearch/issues/128850
516-
- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT
517-
method: test {p0=esql/190_lookup_join/alias-pattern-single}
518-
issue: https://github.com/elastic/elasticsearch/issues/128855
519-
- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT
520-
method: test {p0=esql/191_lookup_join_on_datastreams/data streams supported in LOOKUP JOIN}
521-
issue: https://github.com/elastic/elasticsearch/issues/128856
522510
- class: org.elasticsearch.upgrades.IndexSortUpgradeIT
523511
method: testIndexSortForNumericTypes {upgradedNodes=3}
524512
issue: https://github.com/elastic/elasticsearch/issues/128861

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ static TransportVersion def(int id) {
188188
public static final TransportVersion IDP_CUSTOM_SAML_ATTRIBUTES_ADDED_8_19 = def(8_841_0_40);
189189
public static final TransportVersion DATA_STREAM_OPTIONS_API_REMOVE_INCLUDE_DEFAULTS_8_19 = def(8_841_0_41);
190190
public static final TransportVersion JOIN_ON_ALIASES_8_19 = def(8_841_0_42);
191-
public static final TransportVersion ML_INFERENCE_ELASTIC_RERANK_ADDED_8_19 = def(8_841_0_43);
191+
public static final TransportVersion ILM_ADD_SKIP_SETTING_8_19 = def(8_841_0_43);
192+
public static final TransportVersion ML_INFERENCE_ELASTIC_RERANK_ADDED_8_19 = def(8_841_0_44);
192193
public static final TransportVersion V_9_0_0 = def(9_000_0_09);
193194
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_1 = def(9_000_0_10);
194195
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_2 = def(9_000_0_11);

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleExplainResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ public IndexLifecycleExplainResponse(StreamInput in) throws IOException {
342342
} else {
343343
previousStepInfo = null;
344344
}
345-
if (in.getTransportVersion().onOrAfter(TransportVersions.ILM_ADD_SKIP_SETTING)) {
345+
if (in.getTransportVersion().isPatchFrom(TransportVersions.ILM_ADD_SKIP_SETTING_8_19)
346+
|| in.getTransportVersion().onOrAfter(TransportVersions.ILM_ADD_SKIP_SETTING)) {
346347
skip = in.readBoolean();
347348
} else {
348349
skip = false;
@@ -397,7 +398,8 @@ public void writeTo(StreamOutput out) throws IOException {
397398
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)) {
398399
out.writeOptionalBytesReference(previousStepInfo);
399400
}
400-
if (out.getTransportVersion().onOrAfter(TransportVersions.ILM_ADD_SKIP_SETTING)) {
401+
if (out.getTransportVersion().isPatchFrom(TransportVersions.ILM_ADD_SKIP_SETTING_8_19)
402+
|| out.getTransportVersion().onOrAfter(TransportVersions.ILM_ADD_SKIP_SETTING)) {
401403
out.writeBoolean(skip);
402404
}
403405
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ public enum Cap {
11641164
/**
11651165
* Enable support for index aliases in lookup joins
11661166
*/
1167-
ENABLE_LOOKUP_JOIN_ON_ALIASES(JOIN_LOOKUP_V12.isEnabled());
1167+
ENABLE_LOOKUP_JOIN_ON_ALIASES;
11681168

11691169
private final boolean enabled;
11701170

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public void writeTo(StreamOutput out) throws IOException {
203203
|| out.getTransportVersion().isPatchFrom(TransportVersions.JOIN_ON_ALIASES_8_19)) {
204204
out.writeString(indexPattern);
205205
} else if (indexPattern.equals(shardId.getIndexName()) == false) {
206-
throw new EsqlIllegalArgumentException("Aliases and index patterns are not allowed for LOOKUP JOIN []", indexPattern);
206+
throw new EsqlIllegalArgumentException("Aliases and index patterns are not allowed for LOOKUP JOIN [{}]", indexPattern);
207207
}
208208

209209
out.writeString(inputDataType.typeName());

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceFeatures.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class InferenceFeatures implements FeatureSpecification {
3434
private static final NodeFeature TEST_RULE_RETRIEVER_WITH_INDICES_THAT_DONT_RETURN_RANK_DOCS = new NodeFeature(
3535
"test_rule_retriever.with_indices_that_dont_return_rank_docs"
3636
);
37+
private static final NodeFeature SEMANTIC_TEXT_MATCH_ALL_HIGHLIGHTER = new NodeFeature("semantic_text.match_all_highlighter");
3738

3839
@Override
3940
public Set<NodeFeature> getTestFeatures() {
@@ -57,7 +58,8 @@ public Set<NodeFeature> getTestFeatures() {
5758
SemanticTextFieldMapper.SEMANTIC_TEXT_BIT_VECTOR_SUPPORT,
5859
SemanticTextFieldMapper.SEMANTIC_TEXT_HANDLE_EMPTY_INPUT,
5960
TEST_RULE_RETRIEVER_WITH_INDICES_THAT_DONT_RETURN_RANK_DOCS,
60-
SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG
61+
SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG,
62+
SEMANTIC_TEXT_MATCH_ALL_HIGHLIGHTER
6163
);
6264
}
6365
}

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/highlight/SemanticTextHighlighter.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.lucene.search.IndexSearcher;
1616
import org.apache.lucene.search.KnnByteVectorQuery;
1717
import org.apache.lucene.search.KnnFloatVectorQuery;
18+
import org.apache.lucene.search.MatchAllDocsQuery;
1819
import org.apache.lucene.search.Query;
1920
import org.apache.lucene.search.QueryVisitor;
2021
import org.apache.lucene.search.ScoreMode;
@@ -267,6 +268,8 @@ public void visitLeaf(Query query) {
267268
queries.add(fieldType.createExactKnnQuery(VectorData.fromFloats(knnQuery.getTargetCopy()), null));
268269
} else if (query instanceof KnnByteVectorQuery knnQuery) {
269270
queries.add(fieldType.createExactKnnQuery(VectorData.fromBytes(knnQuery.getTargetCopy()), null));
271+
} else if (query instanceof MatchAllDocsQuery) {
272+
queries.add(new MatchAllDocsQuery());
270273
}
271274
}
272275
});
@@ -293,6 +296,13 @@ public QueryVisitor getSubVisitor(BooleanClause.Occur occur, Query parent) {
293296
}
294297
return this;
295298
}
299+
300+
@Override
301+
public void visitLeaf(Query query) {
302+
if (query instanceof MatchAllDocsQuery) {
303+
queries.add(new MatchAllDocsQuery());
304+
}
305+
}
296306
});
297307
return queries;
298308
}

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/90_semantic_text_highlighter.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,133 @@ setup:
336336
- length: { hits.hits.0.highlight.semantic_text_field: 2 }
337337
- match: { hits.hits.0.highlight.semantic_text_field.0: "some test data" }
338338
- match: { hits.hits.0.highlight.semantic_text_field.1: "now with chunks" }
339+
340+
---
341+
"Highlighting with match_all query":
342+
- requires:
343+
cluster_features: "semantic_text.match_all_highlighter"
344+
reason: semantic text field supports match_all query with semantic highlighter, effective from 8.19 and 9.1.0.
345+
346+
- do:
347+
search:
348+
index: test-sparse-index
349+
body:
350+
query:
351+
match_all: {}
352+
highlight:
353+
fields:
354+
body:
355+
type: "semantic"
356+
number_of_fragments: 2
357+
358+
- match: { hits.total.value: 1 }
359+
- match: { hits.hits.0._id: "doc_1" }
360+
- length: { hits.hits.0.highlight.body: 2 }
361+
- match: { hits.hits.0.highlight.body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
362+
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
363+
364+
- do:
365+
search:
366+
index: test-dense-index
367+
body:
368+
query:
369+
match_all: {}
370+
highlight:
371+
fields:
372+
body:
373+
type: "semantic"
374+
number_of_fragments: 2
375+
376+
- match: { hits.total.value: 1 }
377+
- match: { hits.hits.0._id: "doc_1" }
378+
- length: { hits.hits.0.highlight.body: 2 }
379+
- match: { hits.hits.0.highlight.body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
380+
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
381+
382+
---
383+
"Highlighting with match_all and multi chunks with empty input":
384+
- requires:
385+
cluster_features: "semantic_text.match_all_highlighter"
386+
reason: semantic text field supports match_all query with semantic highlighter, effective from 8.19 and 9.1.0.
387+
388+
- do:
389+
indices.create:
390+
index: test-index-sparse
391+
body:
392+
settings:
393+
index.mapping.semantic_text.use_legacy_format: false
394+
mappings:
395+
properties:
396+
semantic_text_field:
397+
type: semantic_text
398+
inference_id: sparse-inference-id
399+
text_field:
400+
type: text
401+
402+
- do:
403+
index:
404+
index: test-index-sparse
405+
id: doc_1
406+
body:
407+
semantic_text_field: [ "some test data", " ", "now with chunks" ]
408+
text_field: "some test data"
409+
refresh: true
410+
411+
- do:
412+
search:
413+
index: test-index-sparse
414+
body:
415+
query:
416+
match_all: {}
417+
highlight:
418+
fields:
419+
semantic_text_field:
420+
type: "semantic"
421+
number_of_fragments: 2
422+
423+
- match: { hits.total.value: 1 }
424+
- match: { hits.hits.0._id: "doc_1" }
425+
- length: { hits.hits.0.highlight.semantic_text_field: 2 }
426+
- match: { hits.hits.0.highlight.semantic_text_field.0: "some test data" }
427+
- match: { hits.hits.0.highlight.semantic_text_field.1: "now with chunks" }
428+
429+
- do:
430+
indices.create:
431+
index: test-index-dense
432+
body:
433+
settings:
434+
index.mapping.semantic_text.use_legacy_format: false
435+
mappings:
436+
properties:
437+
semantic_text_field:
438+
type: semantic_text
439+
inference_id: dense-inference-id
440+
text_field:
441+
type: text
442+
443+
- do:
444+
index:
445+
index: test-index-dense
446+
id: doc_1
447+
body:
448+
semantic_text_field: [ "some test data", " ", "now with chunks" ]
449+
text_field: "some test data"
450+
refresh: true
451+
452+
- do:
453+
search:
454+
index: test-index-dense
455+
body:
456+
query:
457+
match_all: {}
458+
highlight:
459+
fields:
460+
semantic_text_field:
461+
type: "semantic"
462+
number_of_fragments: 2
463+
464+
- match: { hits.total.value: 1 }
465+
- match: { hits.hits.0._id: "doc_1" }
466+
- length: { hits.hits.0.highlight.semantic_text_field: 2 }
467+
- match: { hits.hits.0.highlight.semantic_text_field.0: "some test data" }
468+
- match: { hits.hits.0.highlight.semantic_text_field.1: "now with chunks" }

0 commit comments

Comments
 (0)