Skip to content

Commit b629d7e

Browse files
committed
Update regex to exclude API calls on the index
1 parent 0641e18 commit b629d7e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
4141

4242
/**
4343
* Doc write operations start with an index name that cannot
44-
* start with -, _ or + and must be lower case.
44+
* start with -, _ or + and must be lower case and are followed
45+
* by the doc type or doc Id. If the 2nd part of the path
46+
* (after the '/') starts with a '_' then it is an API call.
4547
*/
46-
private static final Pattern DOCS_WRITE_OP_PATTERN = Pattern.compile("^[^_\\-\\+][a-z_-]+/");
48+
private static final Pattern DOCS_WRITE_OP_PATTERN = Pattern.compile("^[^_\\-\\+][a-z_-]+/[^_]");
4749

4850
@Input
4951
Map<String, String> setups = new HashMap()

buildSrc/src/test/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTaskTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class RestTestFromSnippetsTaskTest extends GroovyTestCase {
4949
void testIsDocWriteRequest() {
5050
assertTrue(isDocWriteRequest("doc-index/doc_id"));
5151
assertTrue(isDocWriteRequest("doc_index/doc_type/doc_id"));
52-
assertFalse(isDocWriteRequest("doc_index"))
52+
assertFalse(isDocWriteRequest("doc_index/_search"))
5353
assertFalse(isDocWriteRequest("_xpack/ml/datafeeds/datafeed-id/_preview"));
5454
}
5555
}

0 commit comments

Comments
 (0)