Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f4f3c35
Adding Contains function
mjmbischoff Aug 16, 2025
372b4a5
[CI] Auto commit changes from spotless
Aug 16, 2025
7215545
Merge branch 'main' into esql-string-contains
mjmbischoff Aug 16, 2025
5db278a
Fix Contains function return type to BOOLEAN
mjmbischoff Aug 16, 2025
690d18f
Fix incorrect expected results in Contains function tests
mjmbischoff Aug 16, 2025
dc3e82e
Remove redundant assertions in Contains function tests
mjmbischoff Aug 16, 2025
d0f3957
[CI] Auto commit changes from spotless
Aug 16, 2025
bafbc03
Fix ContainsTests return type to match BOOLEAN
mjmbischoff Aug 16, 2025
57cd4a2
Merge branch 'main' into esql-string-contains
mjmbischoff Aug 16, 2025
c45ca9d
Add generated documentation for the CONTAINS function in ESQL
mjmbischoff Aug 16, 2025
11fef88
Update variable name in CONTAINS function examples and docs with nice…
mjmbischoff Aug 16, 2025
b3262cc
Update docs/changelog/133016.yaml
mjmbischoff Aug 16, 2025
bb28101
Add reference under string functions for the CONTAINS function docume…
mjmbischoff Aug 19, 2025
3afaf81
Add reference under string functions for the CONTAINS function docume…
mjmbischoff Aug 19, 2025
4c43deb
Merge branch 'main' into esql-string-contains
mjmbischoff Aug 19, 2025
22f89a2
Removed skip markers from CONTAINS function test cases - wrongfully a…
mjmbischoff Aug 19, 2025
05cf404
Merge branch 'main' into esql-string-contains
mjmbischoff Aug 19, 2025
7385f02
Readding skipped markers as else the test gets run in the backwards c…
mjmbischoff Aug 19, 2025
5db47a2
Merge branch 'main' into esql-string-contains
mjmbischoff Aug 19, 2025
85a442f
Add `required_capability: fn_contains` to trigger CONTAINS test cases…
mjmbischoff Aug 24, 2025
60ebb6b
Remove null checks for `str` and `substr` in CONTAINS function logic
mjmbischoff Aug 24, 2025
e4d293c
Merge branch 'main' into esql-string-contains
mjmbischoff Aug 24, 2025
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/133016.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 133016
summary: Adding Contains ESQL String function
area: ES|QL
type: feature
issues: []

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

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

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

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

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
@@ -1,6 +1,7 @@
* [`BIT_LENGTH`](../../functions-operators/string-functions.md#esql-bit_length)
* [`BYTE_LENGTH`](../../functions-operators/string-functions.md#esql-byte_length)
* [`CONCAT`](../../functions-operators/string-functions.md#esql-concat)
* [`CONTAINS`](../../functions-operators/string-functions.md#esql-contains)
* [`ENDS_WITH`](../../functions-operators/string-functions.md#esql-ends_with)
* [`FROM_BASE64`](../../functions-operators/string-functions.md#esql-from_base64)
* [`HASH`](../../functions-operators/string-functions.md#esql-hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ mapped_pages:
:::{include} ../_snippets/functions/layout/concat.md
:::

:::{include} ../_snippets/functions/layout/contains.md
:::

:::{include} ../_snippets/functions/layout/ends_with.md
:::

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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

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
Expand Up @@ -515,6 +515,21 @@ result:keyword
<em>live long and prosper</em>
;

contains
required_capability: semantic_text_field_caps

FROM semantic_text METADATA _id
| EVAL result = contains(semantic_text_field, "all")
| KEEP _id, result
| SORT _id
;

_id:keyword | result:boolean
1 | false
2 | true
3 | false
;

endsWith
required_capability: semantic_text_field_caps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,92 @@ emp_no:integer | name:keyword
10010 | null
;


contains#[skip:-9.2.99,reason:new string function added in 9.3]
// tag::contains[]
ROW a = "hello"
| EVAL has_ll = CONTAINS(a, "ll")
// end::contains[]
;

// tag::contains-result[]
a:keyword | has_ll:boolean
hello | true
// end::contains-result[]
;

containsFail#[skip:-9.2.99,reason:new string function added in 9.3]
row a = "hello" | eval a_ll = contains(a, "int");

a:keyword | a_ll:boolean
hello | false
;

containsLongerSubstr#[skip:-9.2.99,reason:new string function added in 9.3]
row a = "hello" | eval a_ll = contains(a, "farewell");

a:keyword | a_ll:boolean
hello | false
;

containsSame#[skip:-9.2.99,reason:new string function added in 9.3]
row a = "hello" | eval a_ll = contains(a, "hello");

a:keyword | a_ll:boolean
hello | true
;

containsWithSubstring#[skip:-9.2.99,reason:new string function added in 9.3]
from employees | where emp_no <= 10010 | eval f_s = substring(last_name, 2) | eval f_l = contains(last_name, f_s) | keep emp_no, last_name, f_s, f_l;
ignoreOrder:true

emp_no:integer | last_name:keyword | f_s:keyword | f_l:boolean
10001 | Facello | acello | true
10002 | Simmel | immel | true
10003 | Bamford | amford | true
10004 | Koblick | oblick | true
10005 | Maliniak | aliniak | true
10006 | Preusig | reusig | true
10007 | Zielinski | ielinski | true
10008 | Kalloufi | alloufi | true
10009 | Peac | eac | true
10010 | Piveteau | iveteau | true
;

containsUtf16Emoji#[skip:-9.2.99,reason:new string function added in 9.3]
row a = "🐱Meow!🐶Woof!" | eval f_s = substring(a, 2) | eval f_l = contains(a, f_s);

a:keyword | f_s:keyword | f_l:boolean
🐱Meow!🐶Woof! | Meow!🐶Woof! | true
;

containsNestedCase#[skip:-9.2.99,reason:new string function added in 9.3]
row a = "hello" | eval a_ll = CASE(contains(a, "ll"), "success","fail");

a:keyword | a_ll:keyword
hello | success
;

containsNestSubstring#[skip:-9.2.99,reason:new string function added in 9.3]
row a = "hello" | eval a_ll = contains(substring(a, 2), "ll");

a:keyword | a_ll:boolean
hello | true
;

containsWarnings#[skip:-9.2.99,reason:new string function added in 9.3]

from hosts | where host=="epsilon" | eval l1 = contains(host_group, "ate"), l2 = contains(description, "ate") | keep l1, l2;
ignoreOrder:true
warning:Line 1:82: evaluation of [contains(description, \"ate\")] failed, treating result as null. Only first 20 failures recorded.
warning:Line 1:82: java.lang.IllegalArgumentException: single-value function encountered multi-value

l1:boolean | l2:boolean
true | null
true | null
null | false
;

// Note: no matches in MV returned
in

Expand Down
Loading
Loading