Skip to content

Commit

Permalink
Add Default ELSER 2 Capability (#115891) (#116120)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikep86 authored Nov 1, 2024
1 parent 8c039bf commit 4aac9c7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ tests:
issue: https://github.com/elastic/elasticsearch/issues/113655
- class: org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDateNanosTests
issue: https://github.com/elastic/elasticsearch/issues/113661
- class: org.elasticsearch.xpack.inference.InferenceRestIT
method: test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint}
issue: https://github.com/elastic/elasticsearch/issues/114412
- class: org.elasticsearch.xpack.inference.InferenceRestIT
method: test {p0=inference/40_semantic_text_query/Query a field that uses the default ELSER 2 endpoint}
issue: https://github.com/elastic/elasticsearch/issues/114376
- class: org.elasticsearch.search.retriever.RankDocsRetrieverBuilderTests
method: testRewrite
issue: https://github.com/elastic/elasticsearch/issues/114467
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugin/inference/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apply plugin: 'elasticsearch.internal-yaml-rest-test'

restResources {
restApi {
include '_common', 'bulk', 'indices', 'inference', 'index', 'get', 'update', 'reindex', 'search', 'field_caps'
include '_common', 'bulk', 'indices', 'inference', 'index', 'get', 'update', 'reindex', 'search', 'field_caps', 'capabilities'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
import org.elasticsearch.rest.ServerlessScope;
import org.elasticsearch.rest.action.RestToXContentListener;
import org.elasticsearch.xpack.core.inference.action.GetInferenceModelAction;
import org.elasticsearch.xpack.inference.DefaultElserFeatureFlag;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.xpack.inference.rest.Paths.INFERENCE_ID;
Expand All @@ -26,6 +30,7 @@

@ServerlessScope(Scope.PUBLIC)
public class RestGetInferenceModelAction extends BaseRestHandler {
public static final String DEFAULT_ELSER_2_CAPABILITY = "default_elser_2";

@Override
public String getName() {
Expand Down Expand Up @@ -61,4 +66,14 @@ protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient
var request = new GetInferenceModelAction.Request(inferenceEntityId, taskType);
return channel -> client.execute(GetInferenceModelAction.INSTANCE, request, new RestToXContentListener<>(channel));
}

@Override
public Set<String> supportedCapabilities() {
Set<String> capabilities = new HashSet<>();
if (DefaultElserFeatureFlag.isEnabled()) {
capabilities.add(DEFAULT_ELSER_2_CAPABILITY);
}

return Collections.unmodifiableSet(capabilities);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,12 @@ setup:
---
"Calculates embeddings using the default ELSER 2 endpoint":
- requires:
cluster_features: "semantic_text.default_elser_2"
reason: semantic_text default ELSER 2 inference ID introduced in 8.16.0
reason: "default ELSER 2 inference ID is behind a feature flag"
test_runner_features: [capabilities]
capabilities:
- method: GET
path: /_inference
capabilities: [default_elser_2]

- do:
indices.create:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,12 @@ setup:
---
"Query a field that uses the default ELSER 2 endpoint":
- requires:
cluster_features: "semantic_text.default_elser_2"
reason: semantic_text default ELSER 2 inference ID introduced in 8.16.0
reason: "default ELSER 2 inference ID is behind a feature flag"
test_runner_features: [capabilities]
capabilities:
- method: GET
path: /_inference
capabilities: [default_elser_2]

- do:
indices.create:
Expand Down

0 comments on commit 4aac9c7

Please sign in to comment.