mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 09:54:06 -04:00
This modifies the ESQL test infrastructure to generate more of the documentation for functions. It generates the *Description* section, the *Examples* section, and the *Parameters* section as separate files so we can use them as needed. It also generates a `layout` file that's just a guess as to how to render the whole thing. In some cases it'll work and we can use that instead of hand maintaining a "top level" description file for the function. Most newly generated files are unused. We have to chose to pick them up by replacing the sections we were manually maintaining with an include of the generated section. Or by replacing the entire hand maintained file with the generated top level file. Relates to #104247
64 lines
1.5 KiB
Text
64 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.
|
|
|
|
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]
|
|
|===
|