-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Support using the semantic query across multiple inference IDs #133675
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
Mikep86
merged 21 commits into
elastic:main
from
Mikep86:semantic-text_semantic-query-multi-index-support
Sep 3, 2025
Merged
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2f58cd7
Add InferenceResultsProvider classes
Mikep86 67015d7
Register InferenceResultsProvider classes as named writeables
Mikep86 a24a1e5
Update SemanticQueryBuilder to use InferenceResultsProvider
Mikep86 6b708d1
Updated YAML tests
Mikep86 b067f54
Added comment
Mikep86 7fe8134
Update docs/changelog/133675.yaml
Mikep86 48aa247
Updated changelog
Mikep86 06f29f5
Added SemanticQueryBuilder that takes pre-computed inference results
Mikep86 c7b5390
Add serialization BwC test
Mikep86 5512000
Use a map instead of InferenceResultsProvider
Mikep86 ac844f2
Remove InferenceResultsProvider classes
Mikep86 a69b474
Check for inference errors on the coordinator node
Mikep86 6c6d15b
Fixed ES|QL test
Mikep86 b3ca4e3
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 55e34a1
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
ioanatia e25412c
Update TransportVersions.java after merging main
ioanatia e39bacb
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
elasticmachine d7f877b
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 04a8ac1
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 a8e68c1
Adjust transport version
Mikep86 f1a4f99
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 133675 | ||
summary: Support using the semantic query across multiple inference IDs | ||
area: Vector Search | ||
type: enhancement | ||
issues: [] |
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
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
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
19 changes: 19 additions & 0 deletions
19
...nce/src/main/java/org/elasticsearch/xpack/inference/queries/InferenceResultsProvider.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,19 @@ | ||
/* | ||
* 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.common.io.stream.NamedWriteable; | ||
import org.elasticsearch.inference.InferenceResults; | ||
|
||
import java.util.Collection; | ||
|
||
public interface InferenceResultsProvider extends NamedWriteable { | ||
InferenceResults getInferenceResults(String inferenceId); | ||
|
||
Collection<InferenceResults> getAllInferenceResults(); | ||
} |
70 changes: 70 additions & 0 deletions
70
.../src/main/java/org/elasticsearch/xpack/inference/queries/MapInferenceResultsProvider.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,70 @@ | ||
/* | ||
* 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.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.inference.InferenceResults; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class MapInferenceResultsProvider implements InferenceResultsProvider { | ||
Mikep86 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
public static final String NAME = "map_inference_results_provider"; | ||
|
||
private final Map<String, InferenceResults> inferenceResultsMap; | ||
|
||
public MapInferenceResultsProvider() { | ||
this.inferenceResultsMap = new ConcurrentHashMap<>(); | ||
} | ||
|
||
public MapInferenceResultsProvider(StreamInput in) throws IOException { | ||
this.inferenceResultsMap = in.readImmutableMap(i -> i.readNamedWriteable(InferenceResults.class)); | ||
} | ||
|
||
@Override | ||
public String getWriteableName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeMap(inferenceResultsMap, StreamOutput::writeNamedWriteable); | ||
} | ||
|
||
@Override | ||
public InferenceResults getInferenceResults(String inferenceId) { | ||
return inferenceResultsMap.get(inferenceId); | ||
} | ||
|
||
@Override | ||
public Collection<InferenceResults> getAllInferenceResults() { | ||
return Collections.unmodifiableCollection(inferenceResultsMap.values()); | ||
} | ||
|
||
public void addInferenceResults(String inferenceId, InferenceResults inferenceResults) { | ||
this.inferenceResultsMap.put(inferenceId, inferenceResults); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
MapInferenceResultsProvider that = (MapInferenceResultsProvider) o; | ||
return Objects.equals(inferenceResultsMap, that.inferenceResultsMap); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(inferenceResultsMap); | ||
} | ||
} |
Oops, something went wrong.
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.