Skip to content

[7.x] [DOCS] EQL: Document substring function (#53867) #54203

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 1 commit into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 66 additions & 0 deletions docs/reference/eql/functions.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[[eql-function-ref]]
== EQL function reference
++++
<titleabbrev>Function reference</titleabbrev>
++++

experimental::[]

{es} supports the following EQL functions:

* <<eql-fn-substring>>

[discrete]
[[eql-fn-substring]]
=== `substring`

Extracts a substring from a source string at provided start and end positions.

If no end position is provided, the function extracts the remaining string.

[%collapsible]
====
*Example*
[source,eql]
----
substring("start regsvr32.exe", 6) // returns "regsvr32.exe"
substring("start regsvr32.exe", 0, 5) // returns "start"
substring("start regsvr32.exe", 6, 14) // returns "regsvr32"
substring("start regsvr32.exe", -4) // returns ".exe"
substring("start regsvr32.exe", -4, -1) // returns ".ex"
----

*Syntax*

[source,txt]
----
substring(<source>, <start_pos>[, <end_pos>])
----

*Parameters*

`<source>`::
(Required, string)
Source string.

`<start_pos>`::
+
--
(Required, integer)
Starting position for extraction.

If this position is higher than the `<end_pos>` position or the length of the
`<source>` string, the function returns an empty string.

Positions are zero-indexed. Negative offsets are supported.
--

`<end_pos>`::
(Optional, integer)
Exclusive end position for extraction. If this position is not provided, the
function returns the remaining string.
+
Positions are zero-indexed. Negative offsets are supported.

*Returns:* string
====
2 changes: 2 additions & 0 deletions docs/reference/eql/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Consider using EQL if you:
* <<eql-requirements>>
* <<eql-search>>
* <<eql-syntax>>
* <<eql-function-ref>>
* <<eql-limitations>>

include::requirements.asciidoc[]
include::search.asciidoc[]
include::syntax.asciidoc[]
include::functions.asciidoc[]
include::limitations.asciidoc[]
5 changes: 4 additions & 1 deletion docs/reference/eql/limitations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ experimental::[]
{es} supports a subset of {eql-ref}/index.html[EQL syntax]. {es} cannot run EQL
queries that contain:

* {eql-ref}/functions.html[Functions]
* Array functions:
** {eql-ref}/functions.html#arrayContains[`arrayContains`]
** {eql-ref}/functions.html#arrayCount[`arrayCount`]
** {eql-ref}/functions.html#arraySearch[`arraySearch`]

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

Expand Down
12 changes: 12 additions & 0 deletions docs/reference/eql/syntax.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
[testenv="basic"]
[[eql-syntax]]
== EQL syntax reference
++++
<titleabbrev>Syntax reference</titleabbrev>
++++

experimental::[]

Expand Down Expand Up @@ -283,3 +286,12 @@ dots (`.`), hyphens (`-`), or spaces, must be escaped using backticks (+++`+++).
`my-field`
`my field`
----

[discrete]
[[eql-functions]]
=== Functions

{es} supports several of EQL's built-in functions. You can use these functions
to convert data types, perform math, manipulate strings, and more.

For a list of supported functions, see <<eql-function-ref>>.