Skip to content

Commit a6ba5c6

Browse files
committed
Enable CSS support for inference commands.
1 parent 0d51bcd commit a6ba5c6

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,11 @@ public enum Cap {
17341734
*/
17351735
TOP_SNIPPETS_FUNCTION(Build.current().isSnapshot()),
17361736

1737+
/**
1738+
* Support for inference in cross-cluster search (CCS)
1739+
*/
1740+
INFERENCE_COMMANDS_CCS_SUPPORT,
1741+
17371742
// Last capability should still have a comma for fewer merge conflicts when adding new ones :)
17381743
// This comment prevents the semicolon from being on the previous capability when Spotless formats the file.
17391744
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,10 @@ public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) {
11261126
Literal rowLimit = Literal.integer(source, context.inferenceSettings().rerankRowLimit());
11271127

11281128
return p -> {
1129-
checkForRemoteClusters(p, source, "RERANK");
1129+
if (EsqlCapabilities.Cap.INFERENCE_COMMANDS_CCS_SUPPORT.isEnabled() == false) {
1130+
checkForRemoteClusters(p, source, "RERANK");
1131+
}
1132+
11301133
return applyRerankOptions(
11311134
new Rerank(source, p, rowLimit, queryText, rerankFields, scoreAttribute),
11321135
ctx.commandNamedParameters()
@@ -1177,7 +1180,9 @@ public PlanFactory visitCompletionCommand(EsqlBaseParser.CompletionCommandContex
11771180
Literal rowLimit = Literal.integer(source, context.inferenceSettings().completionRowLimit());
11781181

11791182
return p -> {
1180-
checkForRemoteClusters(p, source, "COMPLETION");
1183+
if (EsqlCapabilities.Cap.INFERENCE_COMMANDS_CCS_SUPPORT.isEnabled() == false) {
1184+
checkForRemoteClusters(p, source, "COMPLETION");
1185+
}
11811186
return applyCompletionOptions(new Completion(source, p, rowLimit, prompt, targetField), ctx.commandNamedParameters());
11821187
};
11831188
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,12 +3818,6 @@ public void testInvalidRerank() {
38183818
expectError("FROM foo* | RERANK ON title WITH inferenceId", "line 1:20: extraneous input 'ON' expecting {QUOTED_STRING");
38193819
expectError("FROM foo* | RERANK \"query text\" WITH inferenceId", "line 1:33: mismatched input 'WITH' expecting 'on'");
38203820

3821-
var fromPatterns = randomIndexPatterns(CROSS_CLUSTER);
3822-
expectError(
3823-
"FROM " + fromPatterns + " | RERANK \"query text\" ON title WITH { \"inference_id\" : \"inference_id\" }",
3824-
"invalid index pattern [" + unquoteIndexPattern(fromPatterns) + "], remote clusters are not supported with RERANK"
3825-
);
3826-
38273821
expectError(
38283822
"FROM foo* | RERANK \"query text\" ON title WITH { \"inference_id\": { \"a\": 123 } }",
38293823
"Option [inference_id] must be a valid string, found [{ \"a\": 123 }]"
@@ -3937,12 +3931,6 @@ public void testInvalidCompletion() {
39373931

39383932
expectError("FROM foo* | COMPLETION completion=prompt WITH", "ine 1:46: mismatched input '<EOF>' expecting '{'");
39393933

3940-
var fromPatterns = randomIndexPatterns(CROSS_CLUSTER);
3941-
expectError(
3942-
"FROM " + fromPatterns + " | COMPLETION prompt_field WITH { \"inference_id\" : \"inference_id\" }",
3943-
"invalid index pattern [" + unquoteIndexPattern(fromPatterns) + "], remote clusters are not supported with COMPLETION"
3944-
);
3945-
39463934
expectError(
39473935
"FROM foo* | COMPLETION prompt WITH { \"inference_id\": { \"a\": 123 } }",
39483936
"line 1:54: Option [inference_id] must be a valid string, found [{ \"a\": 123 }]"

0 commit comments

Comments
 (0)