-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Semantic_text match_all with Highlighter #128702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Samiul-TheSoccerFan
merged 17 commits into
elastic:main
from
Samiul-TheSoccerFan:match_all_with_highlighter
Jun 4, 2025
Merged
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
faa2689
initial implementation for match_All
Samiul-TheSoccerFan ddd7112
reformat
Samiul-TheSoccerFan d9bcbe3
[CI] Auto commit changes from spotless
60da6f4
Excluding matchAllintercepter
Samiul-TheSoccerFan 1139842
Adding matchAllDocs support for vector fields
Samiul-TheSoccerFan 12c1547
[CI] Auto commit changes from spotless
e788bfb
Remove previous implementation
Samiul-TheSoccerFan 9248b7f
Adding yaml tests for match_all
Samiul-TheSoccerFan 4a36076
Merge branch 'main' into match_all_with_highlighter
elasticmachine c53cf5b
fixed yaml tests
Samiul-TheSoccerFan b70dc11
Update docs/changelog/128702.yaml
Samiul-TheSoccerFan 51e21c9
Update changelog
Samiul-TheSoccerFan ed44ca1
changelog - update summary
Samiul-TheSoccerFan 9c86416
Merge branch 'main' into match_all_with_highlighter
elasticmachine 9e42c98
Fix wrong inference names for the yaml tests
Samiul-TheSoccerFan 0ed1798
Merge branch 'main' into match_all_with_highlighter
elasticmachine dc54ae7
Merge branch 'main' into match_all_with_highlighter
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...va/org/elasticsearch/xpack/inference/queries/SemanticMatchAllQueryRewriteInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.inference.queries; | ||
|
|
||
| import org.elasticsearch.features.NodeFeature; | ||
| import org.elasticsearch.index.query.BoolQueryBuilder; | ||
| import org.elasticsearch.index.query.MatchAllQueryBuilder; | ||
| import org.elasticsearch.index.query.QueryBuilder; | ||
|
|
||
| public class SemanticMatchAllQueryRewriteInterceptor extends SemanticQueryRewriteInterceptor { | ||
|
|
||
| public static final NodeFeature SEMANTIC_MATCH_ALL_QUERY_REWRITE_INTERCEPTION_SUPPORTED = new NodeFeature( | ||
| "search.semantic_match_all_query_rewrite_interception_supported" | ||
| ); | ||
|
|
||
| public SemanticMatchAllQueryRewriteInterceptor() {} | ||
|
|
||
| @Override | ||
| protected String getFieldName(QueryBuilder queryBuilder) { | ||
| assert (queryBuilder instanceof MatchAllQueryBuilder); | ||
| return null; // MatchAllQueryBuilder does not have a field name, it matches all documents | ||
| } | ||
|
|
||
| @Override | ||
| protected String getQuery(QueryBuilder queryBuilder) { | ||
| return "*"; // MatchAllQueryBuilder does not have a specific query, it matches all documents | ||
Samiul-TheSoccerFan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| protected QueryBuilder buildInferenceQuery(QueryBuilder queryBuilder, InferenceIndexInformationForField indexInformation) { | ||
| return new SemanticQueryBuilder(indexInformation.fieldName(), getQuery(queryBuilder), false); | ||
| } | ||
|
|
||
| @Override | ||
| protected QueryBuilder buildCombinedInferenceAndNonInferenceQuery( | ||
| QueryBuilder queryBuilder, | ||
| InferenceIndexInformationForField indexInformation | ||
| ) { | ||
| assert (queryBuilder instanceof MatchAllQueryBuilder); | ||
| MatchAllQueryBuilder matchAllQueryBuilder = (MatchAllQueryBuilder) queryBuilder; | ||
| BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); | ||
|
|
||
| boolQueryBuilder.should( | ||
| createSemanticSubQuery(indexInformation.getInferenceIndices(), indexInformation.fieldName(), getQuery(queryBuilder)) | ||
| ); | ||
| boolQueryBuilder.should(createSubQueryForIndices(indexInformation.nonInferenceIndices(), matchAllQueryBuilder)); | ||
| return boolQueryBuilder; | ||
| } | ||
|
|
||
| @Override | ||
| public String getQueryName() { | ||
| return MatchAllQueryBuilder.NAME; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.