Skip to content

Commit 30a3204

Browse files
authored
[DOCS] EQL: Document substring function (#53867)
Adds documentation for the EQL `substring` function. Supporting changes: * Creates a new "EQL function reference" page * Updates the title of the "EQL syntax reference" page for consistency * Adds a brief "Functions" section to the EQL syntax docs * Updates EQL limitations docs to state that only array functions are unsupported
1 parent 4c36b5d commit 30a3204

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

docs/reference/eql/functions.asciidoc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[[eql-function-ref]]
2+
== EQL function reference
3+
++++
4+
<titleabbrev>Function reference</titleabbrev>
5+
++++
6+
7+
experimental::[]
8+
9+
{es} supports the following EQL functions:
10+
11+
* <<eql-fn-substring>>
12+
13+
[discrete]
14+
[[eql-fn-substring]]
15+
=== `substring`
16+
17+
Extracts a substring from a source string at provided start and end positions.
18+
19+
If no end position is provided, the function extracts the remaining string.
20+
21+
[%collapsible]
22+
====
23+
*Example*
24+
[source,eql]
25+
----
26+
substring("start regsvr32.exe", 6) // returns "regsvr32.exe"
27+
substring("start regsvr32.exe", 0, 5) // returns "start"
28+
substring("start regsvr32.exe", 6, 14) // returns "regsvr32"
29+
substring("start regsvr32.exe", -4) // returns ".exe"
30+
substring("start regsvr32.exe", -4, -1) // returns ".ex"
31+
----
32+
33+
*Syntax*
34+
35+
[source,txt]
36+
----
37+
substring(<source>, <start_pos>[, <end_pos>])
38+
----
39+
40+
*Parameters*
41+
42+
`<source>`::
43+
(Required, string)
44+
Source string.
45+
46+
`<start_pos>`::
47+
+
48+
--
49+
(Required, integer)
50+
Starting position for extraction.
51+
52+
If this position is higher than the `<end_pos>` position or the length of the
53+
`<source>` string, the function returns an empty string.
54+
55+
Positions are zero-indexed. Negative offsets are supported.
56+
--
57+
58+
`<end_pos>`::
59+
(Optional, integer)
60+
Exclusive end position for extraction. If this position is not provided, the
61+
function returns the remaining string.
62+
+
63+
Positions are zero-indexed. Negative offsets are supported.
64+
65+
*Returns:* string
66+
====

docs/reference/eql/index.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ Consider using EQL if you:
3232
* <<eql-requirements>>
3333
* <<eql-search>>
3434
* <<eql-syntax>>
35+
* <<eql-function-ref>>
3536
* <<eql-limitations>>
3637

3738
include::requirements.asciidoc[]
3839
include::search.asciidoc[]
3940
include::syntax.asciidoc[]
41+
include::functions.asciidoc[]
4042
include::limitations.asciidoc[]

docs/reference/eql/limitations.asciidoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ experimental::[]
1515
{es} supports a subset of {eql-ref}/index.html[EQL syntax]. {es} cannot run EQL
1616
queries that contain:
1717

18-
* {eql-ref}/functions.html[Functions]
18+
* Array functions:
19+
** {eql-ref}/functions.html#arrayContains[`arrayContains`]
20+
** {eql-ref}/functions.html#arrayCount[`arrayCount`]
21+
** {eql-ref}/functions.html#arraySearch[`arraySearch`]
1922

2023
* {eql-ref}/joins.html[Joins]
2124

docs/reference/eql/syntax.asciidoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
[testenv="basic"]
33
[[eql-syntax]]
44
== EQL syntax reference
5+
++++
6+
<titleabbrev>Syntax reference</titleabbrev>
7+
++++
58

69
experimental::[]
710

@@ -283,3 +286,12 @@ dots (`.`), hyphens (`-`), or spaces, must be escaped using backticks (+++`+++).
283286
`my-field`
284287
`my field`
285288
----
289+
290+
[discrete]
291+
[[eql-functions]]
292+
=== Functions
293+
294+
{es} supports several of EQL's built-in functions. You can use these functions
295+
to convert data types, perform math, manipulate strings, and more.
296+
297+
For a list of supported functions, see <<eql-function-ref>>.

0 commit comments

Comments
 (0)