Skip to content

Commit 45c9760

Browse files
committed
Document return value for locate in case substring is not found
1 parent 44758b3 commit 45c9760

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

docs/reference/esql/functions/description/locate.asciidoc

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/locate.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/docs/locate.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ ip_prefix |Truncates an IP to a given prefix length.
284284
least |Returns the minimum value from multiple columns. This is similar to <<esql-mv_min>> except it is intended to run on multiple columns at once.
285285
left |Returns the substring that extracts 'length' chars from 'string' starting from the left.
286286
length |Returns the character length of a string.
287-
locate |Returns an integer that indicates the position of a keyword substring within another string.
287+
locate |Returns an integer that indicates the position of a keyword substring within another string. Returns `0` if the substring cannot be found.
288288
log |Returns the logarithm of a value to a base. The input can be any numeric value, the return value is always a double. Logs of zero, negative numbers, and base of one return `null` as well as a warning.
289289
log10 |Returns the logarithm of a value to base 10. The input can be any numeric value, the return value is always a double. Logs of 0 and negative numbers return `null` as well as a warning.
290290
ltrim |Removes leading whitespaces from a string.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Locate.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ public class Locate extends EsqlScalarFunction implements OptionalArgument {
4646
private final Expression substr;
4747
private final Expression start;
4848

49-
@FunctionInfo(
50-
returnType = "integer",
51-
description = "Returns an integer that indicates the position of a keyword substring within another string.",
52-
examples = @Example(file = "string", tag = "locate")
53-
)
49+
@FunctionInfo(returnType = "integer", description = """
50+
Returns an integer that indicates the position of a keyword substring within another string.
51+
Returns `0` if the substring cannot be found.""", examples = @Example(file = "string", tag = "locate"))
5452
public Locate(
5553
Source source,
5654
@Param(name = "string", type = { "keyword", "text" }, description = "An input string") Expression str,

0 commit comments

Comments
 (0)