mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 18:03:32 -04:00
* Functions E-Z * Incorporate changes from #103686 * More functions * More functions * Update docs/reference/esql/functions/floor.asciidoc Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> * Update docs/reference/esql/functions/left.asciidoc Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Alexander Spies <alexander.spies@elastic.co> * Review feedback * Fix geo_shape description * Change 'colum'/'field' into 'expressions' * Review feedback * One more --------- Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> Co-authored-by: Alexander Spies <alexander.spies@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
66 lines
1.5 KiB
Text
66 lines
1.5 KiB
Text
[discrete]
|
|
[[esql-substring]]
|
|
=== `SUBSTRING`
|
|
|
|
*Syntax*
|
|
|
|
[.text-center]
|
|
image::esql/functions/signature/substring.svg[Embedded,opts=inline]
|
|
|
|
*Parameters*
|
|
|
|
`str`::
|
|
String expression. If `null`, the function returns `null`.
|
|
|
|
`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*
|
|
|
|
include::types/substring.asciidoc[]
|
|
|
|
*Examples*
|
|
|
|
This example returns the first three characters of every last name:
|
|
|
|
[source.merge.styled,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=substring]
|
|
----
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
|
|===
|
|
include::{esql-specs}/docs.csv-spec[tag=substring-result]
|
|
|===
|
|
|
|
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:
|
|
|
|
[source.merge.styled,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=substringEnd]
|
|
----
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
|
|===
|
|
include::{esql-specs}/docs.csv-spec[tag=substringEnd-result]
|
|
|===
|
|
|
|
If length is omitted, substring returns the remainder of the string. This
|
|
example returns all characters except for the first:
|
|
|
|
[source.merge.styled,esql]
|
|
----
|
|
include::{esql-specs}/docs.csv-spec[tag=substringRemainder]
|
|
----
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
|
|===
|
|
include::{esql-specs}/docs.csv-spec[tag=substringRemainder-result]
|
|
|===
|