-
Notifications
You must be signed in to change notification settings - Fork 25.7k
ES|QL - Allow multivalued query parameters #134317
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
Changes from 15 commits
e534c8b
a30d9ae
3112666
f4f0678
cc4d17e
a72a293
1dd6669
2c95a66
ceccf94
ab1146d
b13d467
21c222a
5ddf1bf
7722600
019c66e
8aa4a9a
6d7e94e
f1909da
a846f9a
b9a03ff
6bbc621
cdbb701
205f920
e199aef
1117aff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 134317 | ||
| summary: ES|QL - Allow multivalued query parameters | ||
| area: ES|QL | ||
| type: enhancement | ||
| issues: [127556, 126710] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,11 @@ | |
| import org.elasticsearch.xpack.esql.VerificationException; | ||
| import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase; | ||
| import org.elasticsearch.xpack.esql.action.EsqlCapabilities; | ||
| import org.elasticsearch.xpack.esql.action.EsqlQueryRequest; | ||
| import org.elasticsearch.xpack.esql.core.type.DataType; | ||
| import org.elasticsearch.xpack.esql.parser.ParserUtils; | ||
| import org.elasticsearch.xpack.esql.parser.QueryParam; | ||
| import org.elasticsearch.xpack.esql.parser.QueryParams; | ||
| import org.junit.Before; | ||
|
|
||
| import java.io.IOException; | ||
|
|
@@ -130,6 +135,38 @@ public void testKnnOptions() { | |
| } | ||
| } | ||
|
|
||
| public void testDenseVectorQueryParams() { | ||
| assumeTrue( | ||
| "multi values for query params capability must be available", | ||
| EsqlCapabilities.Cap.QUERY_PARAMS_MULTI_VALUES.isEnabled() | ||
| ); | ||
|
|
||
| float[] queryVector = new float[numDims]; | ||
| Arrays.fill(queryVector, 0); | ||
| EsqlQueryRequest queryRequest = new EsqlQueryRequest(); | ||
| QueryParams queryParams = new QueryParams( | ||
| List.of(new QueryParam("queryVector", Arrays.asList(queryVector), DataType.INTEGER, ParserUtils.ParamClassification.PATTERN)) | ||
|
||
| ); | ||
|
|
||
| queryRequest.params(queryParams); | ||
|
|
||
| var query = String.format(Locale.ROOT, """ | ||
| FROM test METADATA _score | ||
| | WHERE knn(vector, %s) OR id > 100 | ||
| | KEEP id, _score, vector | ||
| | SORT _score DESC | ||
| | LIMIT 5 | ||
| """, Arrays.toString(queryVector)); | ||
|
|
||
| try (var resp = run(query)) { | ||
| assertColumnNames(resp.columns(), List.of("id", "_score", "vector")); | ||
| assertColumnTypes(resp.columns(), List.of("integer", "double", "dense_vector")); | ||
|
|
||
| List<List<Object>> valuesList = EsqlTestUtils.getValuesList(resp); | ||
| assertEquals(5, valuesList.size()); | ||
| } | ||
| } | ||
|
|
||
| public void testKnnNonPushedDown() { | ||
| float[] queryVector = new float[numDims]; | ||
| Arrays.fill(queryVector, 0.0f); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1467,7 +1467,13 @@ public enum Cap { | |
| /** | ||
| * Support for the Present function | ||
| */ | ||
| FN_PRESENT; | ||
| FN_PRESENT, | ||
|
|
||
| /** | ||
| * Multivalued query parameters | ||
| */ | ||
| QUERY_PARAMS_MULTI_VALUES(Build.current().isSnapshot()); | ||
|
||
|
|
||
|
|
||
| private final boolean enabled; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add data type resolution for lists