Skip to content

Commit 2daacef

Browse files
authored
[8.x] [ES|QL] Enable KQL function as a tech preview (#119730) (#119954)
* [ES|QL] Enable KQL function as a tech preview (#119730) (cherry picked from commit 31f11c3) # Conflicts: # docs/reference/esql/esql-limitations.asciidoc # server/src/main/java/org/elasticsearch/TransportVersions.java # server/src/main/java/org/elasticsearch/rest/action/search/SearchCapabilities.java * Update server/src/main/java/org/elasticsearch/TransportVersions.java
1 parent ae3db60 commit 2daacef

File tree

16 files changed

+21
-75
lines changed

16 files changed

+21
-75
lines changed

docs/changelog/119730.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 119730
2+
summary: Enable KQL function as a tech preview
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/reference/esql/functions/kibana/definition/kql.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/search-functions.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ See <<esql-limitations-full-text-search,full text search limitations>> for infor
1616
{esql} supports these full-text search functions:
1717

1818
// tag::search_list[]
19+
* experimental:[] <<esql-kql>>
1920
* experimental:[] <<esql-match>>
2021
* experimental:[] <<esql-qstr>>
2122
// end::search_list[]
2223

24+
include::layout/kql.asciidoc[]
2325
include::layout/match.asciidoc[]
2426
include::layout/qstr.asciidoc[]

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ static TransportVersion def(int id) {
158158
public static final TransportVersion ESQL_ENABLE_NODE_LEVEL_REDUCTION = def(8_818_00_0);
159159
public static final TransportVersion JINA_AI_INTEGRATION_ADDED = def(8_819_00_0);
160160
public static final TransportVersion TRACK_INDEX_FAILED_DUE_TO_VERSION_CONFLICT_METRIC = def(8_820_00_0);
161+
public static final TransportVersion REPLACE_FAILURE_STORE_OPTIONS_WITH_SELECTOR_SYNTAX = def(8_821_00_0);
162+
public static final TransportVersion ELASTIC_INFERENCE_SERVICE_UNIFIED_CHAT_COMPLETIONS_INTEGRATION = def(8_822_00_0);
163+
public static final TransportVersion KQL_QUERY_TECH_PREVIEW = def(8_823_00_0);
161164

162165
/*
163166
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/rest/action/search/SearchCapabilities.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.rest.action.search;
1111

12-
import org.elasticsearch.Build;
13-
1412
import java.util.HashSet;
1513
import java.util.Set;
1614

@@ -55,9 +53,7 @@ private SearchCapabilities() {}
5553
capabilities.add(KNN_QUANTIZED_VECTOR_RESCORE);
5654
capabilities.add(MOVING_FN_RIGHT_MATH);
5755
capabilities.add(K_DEFAULT_TO_SIZE);
58-
if (Build.current().isSnapshot()) {
59-
capabilities.add(KQL_QUERY_SUPPORTED);
60-
}
56+
capabilities.add(KQL_QUERY_SUPPORTED);
6157
CAPABILITIES = Set.copyOf(capabilities);
6258
}
6359
}

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/KqlFunctionIT.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
import org.elasticsearch.plugins.Plugin;
1616
import org.elasticsearch.xpack.esql.VerificationException;
1717
import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase;
18-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1918
import org.elasticsearch.xpack.kql.KqlPlugin;
2019
import org.junit.Before;
21-
import org.junit.BeforeClass;
2220

2321
import java.util.Collection;
2422
import java.util.List;
@@ -27,12 +25,6 @@
2725
import static org.hamcrest.CoreMatchers.containsString;
2826

2927
public class KqlFunctionIT extends AbstractEsqlIntegTestCase {
30-
31-
@BeforeClass
32-
protected static void ensureKqlFunctionEnabled() {
33-
assumeTrue("kql function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
34-
}
35-
3628
@Before
3729
public void setupIndex() {
3830
createAndPopulateIndex();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ public enum Cap {
445445
/**
446446
* KQL function
447447
*/
448-
KQL_FUNCTION(Build.current().isSnapshot()),
448+
KQL_FUNCTION,
449449

450450
/**
451451
* Hash function

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,10 @@ private static FunctionDefinition[][] functions() {
424424
def(MvSum.class, MvSum::new, "mv_sum"),
425425
def(Split.class, Split::new, "split") },
426426
// fulltext functions
427-
new FunctionDefinition[] { def(Match.class, bi(Match::new), "match"), def(QueryString.class, uni(QueryString::new), "qstr") } };
427+
new FunctionDefinition[] {
428+
def(Kql.class, uni(Kql::new), "kql"),
429+
def(Match.class, bi(Match::new), "match"),
430+
def(QueryString.class, uni(QueryString::new), "qstr") } };
428431

429432
}
430433

@@ -434,7 +437,6 @@ private static FunctionDefinition[][] snapshotFunctions() {
434437
// The delay() function is for debug/snapshot environments only and should never be enabled in a non-snapshot build.
435438
// This is an experimental function and can be removed without notice.
436439
def(Delay.class, Delay::new, "delay"),
437-
def(Kql.class, uni(Kql::new), "kql"),
438440
def(Rate.class, Rate::withUnresolvedTimestamp, "rate"),
439441
def(Term.class, bi(Term::new), "term") } };
440442
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/FullTextWritables.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
2525
entries.add(MultiMatchQueryPredicate.ENTRY);
2626
entries.add(QueryString.ENTRY);
2727
entries.add(Match.ENTRY);
28+
entries.add(Kql.ENTRY);
2829

29-
if (EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled()) {
30-
entries.add(Kql.ENTRY);
31-
}
3230
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
3331
entries.add(Term.ENTRY);
3432
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,6 @@ public void testQueryStringFunctionsNotAllowedAfterCommands() throws Exception {
12611261
}
12621262

12631263
public void testKqlFunctionsNotAllowedAfterCommands() throws Exception {
1264-
// Skip test if the kql function is not enabled.
1265-
assumeTrue("kql function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
1266-
12671264
// Source commands
12681265
assertEquals("1:13: [KQL] function cannot be used after SHOW", error("show info | where kql(\"8.16.0\")"));
12691266
assertEquals("1:17: [KQL] function cannot be used after ROW", error("row a= \"Anna\" | where kql(\"Anna\")"));
@@ -1321,9 +1318,6 @@ public void testQueryStringFunctionOnlyAllowedInWhere() throws Exception {
13211318
}
13221319

13231320
public void testKqlFunctionOnlyAllowedInWhere() throws Exception {
1324-
// Skip test if the kql function is not enabled.
1325-
assumeTrue("kql function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
1326-
13271321
assertEquals("1:9: [KQL] function is only supported in WHERE commands", error("row a = kql(\"Anna\")"));
13281322
checkFullTextFunctionsOnlyAllowedInWhere("KQL", "kql(\"Anna\")", "function");
13291323
}
@@ -1375,9 +1369,6 @@ public void testQueryStringFunctionArgNotNullOrConstant() throws Exception {
13751369
}
13761370

13771371
public void testKqlFunctionArgNotNullOrConstant() throws Exception {
1378-
// Skip test if the kql function is not enabled.
1379-
assumeTrue("kql function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
1380-
13811372
assertEquals(
13821373
"1:19: argument of [kql(first_name)] must be a constant, received [first_name]",
13831374
error("from test | where kql(first_name)")
@@ -1391,9 +1382,6 @@ public void testQueryStringWithDisjunctions() {
13911382
}
13921383

13931384
public void testKqlFunctionWithDisjunctions() {
1394-
// Skip test if the kql function is not enabled.
1395-
assumeTrue("kql function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
1396-
13971385
checkWithDisjunctions("KQL", "kql(\"first_name: Anna\")", "function");
13981386
}
13991387

@@ -1436,8 +1424,6 @@ public void testFullTextFunctionsDisjunctions() {
14361424
checkWithFullTextFunctionsDisjunctions("MATCH", "match(last_name, \"Smith\")", "function");
14371425
checkWithFullTextFunctionsDisjunctions(":", "last_name : \"Smith\"", "operator");
14381426
checkWithFullTextFunctionsDisjunctions("QSTR", "qstr(\"last_name: Smith\")", "function");
1439-
1440-
assumeTrue("KQL function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
14411427
checkWithFullTextFunctionsDisjunctions("KQL", "kql(\"last_name: Smith\")", "function");
14421428
}
14431429

@@ -1466,9 +1452,6 @@ public void testQueryStringFunctionWithNonBooleanFunctions() {
14661452
}
14671453

14681454
public void testKqlFunctionWithNonBooleanFunctions() {
1469-
// Skip test if the kql function is not enabled.
1470-
assumeTrue("kql function capability not available", EsqlCapabilities.Cap.KQL_FUNCTION.isEnabled());
1471-
14721455
checkFullTextFunctionsWithNonBooleanFunctions("KQL", "kql(\"first_name: Anna\")", "function");
14731456
}
14741457

0 commit comments

Comments
 (0)