Skip to content

Commit 777699a

Browse files
Fix docs and add more UTs
1 parent 009a81c commit 777699a

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

docs/reference/query-languages/esql/_snippets/operators/detailedDescription/rlike.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@ ROW message = "foo ( bar"
1010
```
1111

1212

13+
To reduce the overhead of escaping, we suggest using triple quotes strings `"""`
14+
1315
```esql
14-
ROW message = "foobar"
15-
| WHERE message RLIKE ("foo.*", "bar.")
16+
ROW message = "foo ( bar"
17+
| WHERE message RLIKE """foo \( bar"""
1618
```
1719

1820

19-
To reduce the overhead of escaping, we suggest using triple quotes strings `"""`
21+
```{applies_to}
22+
stack: ga 9.1
23+
serverless: ga
24+
```
25+
Both a single pattern or a list of patterns are supported. If a list of patterns is provided,
26+
the expression will return true if any of the patterns match.
2027

2128
```esql
22-
ROW message = "foo ( bar"
23-
| WHERE message RLIKE """foo \( bar"""
29+
ROW message = "foobar"
30+
| WHERE message RLIKE ("foo.*", "bar.")
2431
```
2532

2633

docs/reference/query-languages/esql/kibana/definition/operators/not rlike.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/query-languages/esql/kibana/definition/operators/rlike.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/query-languages/esql/kibana/docs/operators/not rlike.md

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/query-languages/esql/kibana/docs/operators/rlike.md

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

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,34 @@ public void testNotRLikeIndex() throws Exception {
565565
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, false);
566566
}
567567

568+
public void testRLikeListIndex() throws Exception {
569+
assumeTrue("not supported", capabilitiesSupportedNewAndOld(List.of("rlike_with_list_of_patterns")));
570+
boolean includeCCSMetadata = includeCCSMetadata();
571+
Map<String, Object> result = run("""
572+
FROM test-local-index,*:test-remote-index METADATA _index
573+
| WHERE _index RLIKE (".*remote.*", ".*not-exist.*")
574+
| STATS c = COUNT(*) BY _index
575+
| SORT _index ASC
576+
""", includeCCSMetadata);
577+
var columns = List.of(Map.of("name", "c", "type", "long"), Map.of("name", "_index", "type", "keyword"));
578+
var values = List.of(List.of(remoteDocs.size(), REMOTE_CLUSTER_NAME + ":" + remoteIndex));
579+
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, false);
580+
}
581+
582+
public void testNotRLikeListIndex() throws Exception {
583+
assumeTrue("not supported", capabilitiesSupportedNewAndOld(List.of("rlike_with_list_of_patterns")));
584+
boolean includeCCSMetadata = includeCCSMetadata();
585+
Map<String, Object> result = run("""
586+
FROM test-local-index,*:test-remote-index METADATA _index
587+
| WHERE _index NOT RLIKE (".*remote.*", ".*not-exist.*")
588+
| STATS c = COUNT(*) BY _index
589+
| SORT _index ASC
590+
""", includeCCSMetadata);
591+
var columns = List.of(Map.of("name", "c", "type", "long"), Map.of("name", "_index", "type", "keyword"));
592+
var values = List.of(List.of(localDocs.size(), localIndex));
593+
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, false);
594+
}
595+
568596
private RestClient remoteClusterClient() throws IOException {
569597
var clusterHosts = parseClusterHosts(remoteCluster.getHttpAddresses());
570598
return buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[0]));

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,25 @@ public class RLike extends RegexMatch<RLikePattern> {
3333
Use `RLIKE` to filter data based on string patterns using using
3434
<<regexp-syntax,regular expressions>>. `RLIKE` usually acts on a field placed on
3535
the left-hand side of the operator, but it can also act on a constant (literal)
36-
expression. The right-hand side of the operator represents the pattern or a list of patterns.""", detailedDescription = """
36+
expression. The right-hand side of the operator represents the pattern.""", detailedDescription = """
3737
Matching special characters (eg. `.`, `*`, `(`...) will require escaping.
3838
The escape character is backslash `\\`. Since also backslash is a special character in string literals,
3939
it will require further escaping.
4040
4141
<<load-esql-example, file=string tag=rlikeEscapingSingleQuotes>>
4242
43-
<<load-esql-example, file=where-like tag=rlikeListDocExample>>
44-
4543
To reduce the overhead of escaping, we suggest using triple quotes strings `\"\"\"`
4644
4745
<<load-esql-example, file=string tag=rlikeEscapingTripleQuotes>>
46+
47+
```{applies_to}
48+
stack: ga 9.1
49+
serverless: ga
50+
```
51+
Both a single pattern or a list of patterns are supported. If a list of patterns is provided,
52+
the expression will return true if any of the patterns match.
53+
54+
<<load-esql-example, file=where-like tag=rlikeListDocExample>>
4855
""", operator = NAME, examples = @Example(file = "docs", tag = "rlike"))
4956
public RLike(
5057
Source source,

0 commit comments

Comments
 (0)