mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 18:03:32 -04:00
* [docs] Migrate docs from AsciiDoc to Markdown (#123507) * delete asciidoc files * add migrated files * fix errors * Disable docs tests * Clarify release notes page titles * Revert "Clarify release notes page titles" This reverts commit8be688648d
. * Comment out edternal URI images * Clean up query languages landing pages, link to conceptual docs * Add .md to url * Fixes inference processor nesting. --------- Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> Co-authored-by: Liam Thompson <leemthompo@gmail.com> Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com> Co-authored-by: István Zoltán Szabó <szabosteve@gmail.com> (cherry picked from commitb7e3a1e14b
) # Conflicts: # docs/build.gradle # docs/reference/migration/index.asciidoc # docs/reference/migration/migrate_9_0.asciidoc # docs/reference/release-notes.asciidoc # docs/reference/release-notes/9.0.0.asciidoc # docs/reference/release-notes/highlights.asciidoc * Fix build file * Really fix build file --------- Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com>
1.7 KiB
1.7 KiB
SUBSTRING
[esql-substring]
Syntax
:::{image} ../../../../../images/substring.svg :alt: Embedded :class: text-center :::
Parameters
string
- String expression. If
null
, the function returnsnull
. start
- Start position.
length
- Length of the substring from the start position. Optional; if omitted, all positions after
start
are returned.
Description
Returns a substring of a string, specified by a start position and an optional length.
Supported types
string | start | length | result |
---|---|---|---|
keyword | integer | integer | keyword |
text | integer | integer | keyword |
Examples
This example returns the first three characters of every last name:
FROM employees
| KEEP last_name
| EVAL ln_sub = SUBSTRING(last_name, 1, 3)
last_name:keyword | ln_sub:keyword |
---|---|
Awdeh | Awd |
Azuma | Azu |
Baek | Bae |
Bamford | Bam |
Bernatsky | Ber |
A negative start position is interpreted as being relative to the end of the string. This example returns the last three characters of of every last name:
FROM employees
| KEEP last_name
| EVAL ln_sub = SUBSTRING(last_name, -3, 3)
last_name:keyword | ln_sub:keyword |
---|---|
Awdeh | deh |
Azuma | uma |
Baek | aek |
Bamford | ord |
Bernatsky | sky |
If length is omitted, substring returns the remainder of the string. This example returns all characters except for the first:
FROM employees
| KEEP last_name
| EVAL ln_sub = SUBSTRING(last_name, 2)
last_name:keyword | ln_sub:keyword |
---|---|
Awdeh | wdeh |
Azuma | zuma |
Baek | aek |
Bamford | amford |
Bernatsky | ernatsky |