Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2f58cd7
Add InferenceResultsProvider classes
Mikep86 Aug 27, 2025
67015d7
Register InferenceResultsProvider classes as named writeables
Mikep86 Aug 27, 2025
a24a1e5
Update SemanticQueryBuilder to use InferenceResultsProvider
Mikep86 Aug 27, 2025
6b708d1
Updated YAML tests
Mikep86 Aug 27, 2025
b067f54
Added comment
Mikep86 Aug 27, 2025
7fe8134
Update docs/changelog/133675.yaml
Mikep86 Aug 27, 2025
48aa247
Updated changelog
Mikep86 Aug 27, 2025
06f29f5
Added SemanticQueryBuilder that takes pre-computed inference results
Mikep86 Aug 27, 2025
c7b5390
Add serialization BwC test
Mikep86 Aug 28, 2025
5512000
Use a map instead of InferenceResultsProvider
Mikep86 Aug 28, 2025
ac844f2
Remove InferenceResultsProvider classes
Mikep86 Aug 28, 2025
a69b474
Check for inference errors on the coordinator node
Mikep86 Aug 28, 2025
6c6d15b
Fixed ES|QL test
Mikep86 Aug 28, 2025
b3ca4e3
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 Aug 28, 2025
55e34a1
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
ioanatia Sep 2, 2025
e25412c
Update TransportVersions.java after merging main
ioanatia Sep 2, 2025
e39bacb
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
elasticmachine Sep 2, 2025
d7f877b
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 Sep 2, 2025
04a8ac1
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 Sep 2, 2025
a8e68c1
Adjust transport version
Mikep86 Sep 2, 2025
f1a4f99
Merge branch 'main' into semantic-text_semantic-query-multi-index-sup…
Mikep86 Sep 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/133675.yaml
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: []
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ static TransportVersion def(int id) {
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS = def(9_127_0_00);
public static final TransportVersion PROJECT_RESERVED_STATE_MOVE_TO_REGISTRY = def(9_147_0_00);
public static final TransportVersion STREAMS_ENDPOINT_PARAM_RESTRICTIONS = def(9_148_00_00);
public static final TransportVersion SEMANTIC_QUERY_MULTIPLE_INFERENCE_IDS = def(9_149_00_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,28 @@ public abstract class SemanticMatchTestCase extends ESRestTestCase {
public void testWithMultipleInferenceIds() throws IOException {
assumeTrue("semantic text capability not available", EsqlCapabilities.Cap.SEMANTIC_TEXT_FIELD_CAPS.isEnabled());

var request1 = new Request("POST", "/test-semantic1/_doc/id-1");
request1.addParameter("refresh", "true");
request1.setJsonEntity("{\"semantic_text_field\": \"inference test 1\"}");
assertEquals(201, adminClient().performRequest(request1).getStatusLine().getStatusCode());

var request2 = new Request("POST", "/test-semantic2/_doc/id-2");
request2.addParameter("refresh", "true");
request2.setJsonEntity("{\"semantic_text_field\": \"inference test 2\"}");
assertEquals(201, adminClient().performRequest(request2).getStatusLine().getStatusCode());

String query = """
from test-semantic1,test-semantic2
| where match(semantic_text_field, "something")
| SORT semantic_text_field ASC
""";
ResponseException re = expectThrows(ResponseException.class, () -> runEsqlQuery(query));

assertThat(re.getMessage(), containsString("Field [semantic_text_field] has multiple inference IDs associated with it"));
Map<String, Object> result = runEsqlQuery(query);

assertEquals(400, re.getResponse().getStatusLine().getStatusCode());
assertResultMap(
result,
matchesList().item(matchesMap().entry("name", "semantic_text_field").entry("type", "text")),
matchesList(List.of(List.of("inference test 1"), List.of("inference test 2")))
);
}

public void testWithInferenceNotConfigured() {
Expand Down Expand Up @@ -128,6 +141,28 @@ public void setUpIndices() throws IOException {
createIndex(adminClient(), "test-semantic4", settings, mapping4);
}

@Before
public void setUpSparseEmbeddingInferenceEndpoint() throws IOException {
Request request = new Request("PUT", "_inference/sparse_embedding/test_sparse_inference");
request.setJsonEntity("""
{
"service": "test_service",
"service_settings": {
"model": "my_model",
"api_key": "abc64"
},
"task_settings": {
}
}
""");
try {
adminClient().performRequest(request);
} catch (ResponseException exc) {
// in case the removal failed
assertThat(exc.getResponse().getStatusLine().getStatusCode(), equalTo(400));
}
}

@Before
public void setUpTextEmbeddingInferenceEndpoint() throws IOException {
Request request = new Request("PUT", "_inference/text_embedding/test_dense_inference");
Expand Down Expand Up @@ -155,6 +190,15 @@ public void setUpTextEmbeddingInferenceEndpoint() throws IOException {
public void wipeData() throws IOException {
adminClient().performRequest(new Request("DELETE", "*"));

try {
adminClient().performRequest(new Request("DELETE", "_inference/test_sparse_inference"));
} catch (ResponseException e) {
// 404 here means the endpoint was not created
if (e.getResponse().getStatusLine().getStatusCode() != 404) {
throw e;
}
}

try {
adminClient().performRequest(new Request("DELETE", "_inference/test_dense_inference"));
} catch (ResponseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.xpack.inference.mapper.SemanticInferenceMetadataFieldsMapper;
import org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper;
import org.elasticsearch.xpack.inference.queries.SemanticQueryBuilder;
import org.elasticsearch.xpack.inference.rank.textsimilarity.TextSimilarityRankRetrieverBuilder;

import java.util.HashSet;
Expand Down Expand Up @@ -82,7 +83,8 @@ public Set<NodeFeature> getTestFeatures() {
SEMANTIC_QUERY_REWRITE_INTERCEPTORS_PROPAGATE_BOOST_AND_QUERY_NAME_FIX,
SEMANTIC_TEXT_HIGHLIGHTING_FLAT,
SEMANTIC_TEXT_SPARSE_VECTOR_INDEX_OPTIONS,
SEMANTIC_TEXT_FIELDS_CHUNKS_FORMAT
SEMANTIC_TEXT_FIELDS_CHUNKS_FORMAT,
SemanticQueryBuilder.SEMANTIC_QUERY_MULTIPLE_INFERENCE_IDS
)
);
if (RERANK_SNIPPETS.isEnabled()) {
Expand Down
Loading