Skip to content
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
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/description/locate.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/esql/functions/kibana/docs/locate.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ ip_prefix |Truncates an IP to a given prefix length.
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.
left |Returns the substring that extracts 'length' chars from 'string' starting from the left.
length |Returns the character length of a string.
locate |Returns an integer that indicates the position of a keyword substring within another string.
locate |Returns an integer that indicates the position of a keyword substring within another string. Returns `0` if the substring cannot be found. Note that string positions start from `1`.
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.
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.
ltrim |Removes leading whitespaces from a string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ public class Locate extends EsqlScalarFunction implements OptionalArgument {
private final Expression substr;
private final Expression start;

@FunctionInfo(
returnType = "integer",
description = "Returns an integer that indicates the position of a keyword substring within another string.",
examples = @Example(file = "string", tag = "locate")
)
@FunctionInfo(returnType = "integer", description = """
Returns an integer that indicates the position of a keyword substring within another string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns an integer (starting from 1) that indicates the position of a keyword substring within another string.
Returns 0 if the substring is not found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many developers are not used with string positions starting from 1. This is why I kind of like to have that as a separate note. If you feel very strongly about I can change this again, but for now I will merge the PR as it is.

Returns `0` if the substring cannot be found.
Note that string positions start from `1`.""", examples = @Example(file = "string", tag = "locate"))
public Locate(
Source source,
@Param(name = "string", type = { "keyword", "text" }, description = "An input string") Expression str,
Expand Down