Skip to content

Commit 4969fca

Browse files
committed
Categorize docs
1 parent 444d6c1 commit 4969fca

File tree

8 files changed

+60
-6
lines changed

8 files changed

+60
-6
lines changed

docs/reference/esql/functions/description/categorize.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/examples/categorize.asciidoc

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

docs/reference/esql/functions/grouping-functions.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The <<esql-stats-by>> command supports these grouping functions:
99

1010
// tag::group_list[]
1111
* <<esql-bucket>>
12+
* <<esql-categorize>>
1213
// end::group_list[]
1314

1415
include::layout/bucket.asciidoc[]

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

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

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

docs/reference/esql/functions/layout/categorize.asciidoc

Lines changed: 3 additions & 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/docs.csv-spec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,20 @@ Ahmedabad | 9 | 72
676676
Bangalore | 9 | 72
677677
// end::bitLength-result[]
678678
;
679+
680+
docsCategorize
681+
required_capability: categorize_v4
682+
// tag::docsCategorize[]
683+
FROM sample_data
684+
| STATS count=COUNT() BY category=CATEGORIZE(message)
685+
// end::docsCategorize[]
686+
| SORT category
687+
;
688+
689+
// tag::docsCategorize[]
690+
count:long | category:keyword
691+
3 | .*?Connected.+?to.*?
692+
3 | .*?Connection.+?error.*?
693+
1 | .*?Disconnected.*?
694+
// end::docsCategorize[]
695+
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/grouping/Categorize.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
1717
import org.elasticsearch.xpack.esql.core.tree.Source;
1818
import org.elasticsearch.xpack.esql.core.type.DataType;
19+
import org.elasticsearch.xpack.esql.expression.function.Example;
1920
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
2021
import org.elasticsearch.xpack.esql.expression.function.Param;
2122
import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
@@ -44,10 +45,21 @@ public class Categorize extends GroupingFunction implements Validatable {
4445

4546
private final Expression field;
4647

47-
@FunctionInfo(returnType = "keyword", description = "Categorizes text messages.")
48+
@FunctionInfo(
49+
returnType = "keyword",
50+
description = "Groups text messages into categories of similarly formatted text values.",
51+
examples = {
52+
@Example(
53+
file = "docs",
54+
tag = "docsCategorize",
55+
description = "This example categorizes server logs messages into categories and aggregates their counts. "
56+
) },
57+
preview = true
58+
)
4859
public Categorize(
4960
Source source,
5061
@Param(name = "field", type = { "text", "keyword" }, description = "Expression to categorize") Expression field
62+
5163
) {
5264
super(source, List.of(field));
5365
this.field = field;

0 commit comments

Comments
 (0)