Skip to content

Term query for ES|QL #117359

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

Merged
merged 56 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
89e3539
21m draft
tteofili Nov 22, 2024
d49eaa5
term tests
tteofili Nov 22, 2024
0a09964
term tests
tteofili Nov 22, 2024
5cb1e14
Merge branch 'main' into esql_termq
tteofili Nov 22, 2024
3dbbb5b
Update docs/changelog/117359.yaml
tteofili Nov 22, 2024
2d51477
add to esql_capability
tteofili Nov 22, 2024
f473fde
Merge branch 'esql_termq' of github.com:tteofili/elasticsearch into e…
tteofili Nov 22, 2024
40535e2
dropped unused import
tteofili Nov 22, 2024
30c70fb
Merge branch 'main' into esql_termq
tteofili Nov 22, 2024
5d3cc94
test fix
tteofili Nov 22, 2024
f9cca48
Merge branch 'esql_termq' of github.com:tteofili/elasticsearch into e…
tteofili Nov 22, 2024
f7e4d08
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Nov 22, 2024
1ca23a2
spotless
tteofili Nov 25, 2024
5975ac9
Merge branch 'main' into esql_termq
tteofili Nov 25, 2024
a0ace64
test fixes
tteofili Nov 25, 2024
fc08732
Merge branch 'main' into esql_termq
tteofili Nov 25, 2024
fdb6818
snapshot build only
tteofili Nov 26, 2024
de1d5fc
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Nov 26, 2024
f9bf66b
merge fix
tteofili Nov 26, 2024
edce0bb
Merge branch 'esql_termq' of github.com:tteofili/elasticsearch into e…
tteofili Nov 26, 2024
8175a3e
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Nov 26, 2024
1dd232e
test fix
tteofili Nov 26, 2024
f87669d
Merge branch 'main' into esql_termq
tteofili Nov 26, 2024
d8d029a
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 2, 2024
725d2e5
csv tests, minor fix
tteofili Dec 2, 2024
178ff5c
minor test fix
tteofili Dec 2, 2024
f874993
verifier tests
tteofili Dec 2, 2024
1ddd42b
more tests
tteofili Dec 2, 2024
a664329
avoid running IT if term() not enabled
tteofili Dec 2, 2024
d18326d
test fix
tteofili Dec 3, 2024
5f72e54
added docs (kibana only)
tteofili Dec 3, 2024
72ff726
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 3, 2024
04d2e1e
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 3, 2024
3f57205
test fixes
tteofili Dec 3, 2024
4529980
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 3, 2024
341b7a3
capitalize grammar words in example
tteofili Dec 3, 2024
f295850
minor doc fix
tteofili Dec 3, 2024
17e64bd
Merge branch 'main' into esql_termq
ChrisHegarty Dec 4, 2024
1bd7700
fix test
ChrisHegarty Dec 4, 2024
341aa46
Merge branch 'main' into esql_termq
ChrisHegarty Dec 4, 2024
43d0d14
Merge branch 'main' into esql_termq
ChrisHegarty Dec 4, 2024
eabe44e
another test fix
ChrisHegarty Dec 4, 2024
f5ad3e7
Merge branch 'main' into esql_termq
ChrisHegarty Dec 4, 2024
630130b
Merge branch 'main' into esql_termq
ChrisHegarty Dec 4, 2024
011c6d3
Merge branch 'main' into esql_termq
ChrisHegarty Dec 4, 2024
d120e4e
Merge branch 'main' into esql_termq
ChrisHegarty Dec 5, 2024
233e9b9
Merge branch 'main' into esql_termq
ChrisHegarty Dec 5, 2024
1628fd4
move func registry to snapshot
ChrisHegarty Dec 5, 2024
21a947f
revert typo
ChrisHegarty Dec 5, 2024
9dbaa58
revert typo
ChrisHegarty Dec 5, 2024
0463956
Merge branch 'main' into esql_termq
ChrisHegarty Dec 5, 2024
d9acb0e
check for term capability in plan optimizer test
ChrisHegarty Dec 5, 2024
d679dc5
fix capability check in verifier tests
ChrisHegarty Dec 5, 2024
4c5b7dc
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 5, 2024
9200b90
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 5, 2024
1be48f6
Merge branch 'main' of github.com:elastic/elasticsearch into esql_termq
tteofili Dec 6, 2024
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/117359.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117359
summary: Term query for ES|QL
area: ES|QL
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/reference/esql/functions/description/term.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/reference/esql/functions/examples/term.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions docs/reference/esql/functions/kibana/definition/term.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/reference/esql/functions/kibana/docs/term.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions docs/reference/esql/functions/layout/term.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions docs/reference/esql/functions/parameters/term.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/reference/esql/functions/signature/term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions docs/reference/esql/functions/types/term.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
###############################################
# Tests for Term function
#

termWithTextField
required_capability: term_function

// tag::term-with-field[]
FROM books
| WHERE TERM(author, "gabriel")
| KEEP book_no, title
| LIMIT 3;
// end::term-with-field[]
ignoreOrder:true

book_no:keyword | title:text
4814 | El Coronel No Tiene Quien Le Escriba / No One Writes to the Colonel (Spanish Edition)
4917 | Autumn of the Patriarch
6380 | La hojarasca (Spanish Edition)
;

termWithKeywordField
required_capability: term_function

from employees
| where term(first_name, "Guoxiang")
| keep emp_no, first_name;

// tag::term-with-keyword-field-result[]
emp_no:integer | first_name:keyword
10015 | Guoxiang
;
// end::term-with-keyword-field-result[]

termWithQueryExpressions
required_capability: term_function

from books
| where term(author, CONCAT("gab", "riel"))
| keep book_no, title;
ignoreOrder:true

book_no:keyword | title:text
4814 | El Coronel No Tiene Quien Le Escriba / No One Writes to the Colonel (Spanish Edition)
4917 | Autumn of the Patriarch
6380 | La hojarasca (Spanish Edition)
;

termAfterKeep
required_capability: term_function

from books
| keep book_no, author
| where term(author, "faulkner")
| sort book_no
| limit 5;

book_no:keyword | author:text
2378 | [Carol Faulkner, Holly Byers Ochoa, Lucretia Mott]
2713 | William Faulkner
2847 | Colleen Faulkner
2883 | William Faulkner
3293 | Danny Faulkner
;

termAfterDrop
required_capability: term_function

from books
| drop ratings, description, year, publisher, title, author.keyword
| where term(author, "william")
| keep book_no, author
| sort book_no
| limit 2;

book_no:keyword | author:text
2713 | William Faulkner
2883 | William Faulkner
;

termAfterEval
required_capability: term_function

from books
| eval stars = to_long(ratings / 2.0)
| where term(author, "colleen")
| sort book_no
| keep book_no, author, stars
| limit 2;

book_no:keyword | author:text | stars:long
2847 | Colleen Faulkner | 3
4502 | Colleen Faulkner | 3
;

termWithConjunction
required_capability: term_function

from books
| where term(author, "tolkien") and ratings > 4.95
| eval author = mv_sort(author)
| keep book_no, ratings, author;
ignoreOrder:true

book_no:keyword | ratings:double | author:keyword
2301 | 5.0 | John Ronald Reuel Tolkien
3254 | 5.0 | [Christopher Tolkien, John Ronald Reuel Tolkien]
7350 | 5.0 | [Christopher Tolkien, John Ronald Reuel Tolkien]
;

termWithConjunctionAndSort
required_capability: term_function

from books
| where term(author, "tolkien") and ratings > 4.95
| eval author = mv_sort(author)
| keep book_no, ratings, author
| sort book_no;

book_no:keyword | ratings:double | author:keyword
2301 | 5.0 | John Ronald Reuel Tolkien
3254 | 5.0 | [Christopher Tolkien, John Ronald Reuel Tolkien]
7350 | 5.0 | [Christopher Tolkien, John Ronald Reuel Tolkien]
;

termWithFunctionPushedToLucene
required_capability: term_function

from hosts
| where term(host, "beta") and cidr_match(ip1, "127.0.0.2/32", "127.0.0.3/32")
| keep card, host, ip0, ip1;
ignoreOrder:true

card:keyword |host:keyword |ip0:ip |ip1:ip
eth1 |beta |127.0.0.1 |127.0.0.2
;

termWithNonPushableConjunction
required_capability: term_function

from books
| where term(title, "rings") and length(title) > 75
| keep book_no, title;
ignoreOrder:true

book_no:keyword | title:text
4023 | A Tolkien Compass: Including J. R. R. Tolkien's Guide to the Names in The Lord of the Rings
;

termWithMultipleWhereClauses
required_capability: term_function

from books
| where term(title, "rings")
| where term(title, "lord")
| keep book_no, title;
ignoreOrder:true

book_no:keyword | title:text
2675 | The Lord of the Rings - Boxed Set
2714 | Return of the King Being the Third Part of The Lord of the Rings
4023 | A Tolkien Compass: Including J. R. R. Tolkien's Guide to the Names in The Lord of the Rings
7140 | The Lord of the Rings Poster Collection: Six Paintings by Alan Lee (No. 1)
;

termWithMultivaluedField
required_capability: term_function

from employees
| where term(job_positions, "Data Scientist")
| keep emp_no, first_name, last_name
| sort emp_no asc
| limit 2;
ignoreOrder:true

emp_no:integer | first_name:keyword | last_name:keyword
10014 | Berni | Genin
10017 | Cristinel | Bouloucos
;

testWithMultiValuedFieldWithConjunction
required_capability: term_function

from employees
| where term(job_positions, "Data Scientist") and term(first_name, "Cristinel")
| keep emp_no, first_name, last_name
| limit 1;

emp_no:integer | first_name:keyword | last_name:keyword
10017 | Cristinel | Bouloucos
;

termWithConjQueryStringFunctions
required_capability: term_function
required_capability: qstr_function

from employees
| where term(job_positions, "Data Scientist") and qstr("first_name: Cristinel and gender: F")
| keep emp_no, first_name, last_name
| sort emp_no ASC
| limit 1;
ignoreOrder:true

emp_no:integer | first_name:keyword | last_name:keyword
10017 | Cristinel | Bouloucos
;
Loading