Skip to content

Commit

Permalink
Optimized ES regexp queries
Browse files Browse the repository at this point in the history
  • Loading branch information
EinsamHauer committed Oct 19, 2022
1 parent c904e9f commit b961135
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>net.iponweb.disthene.reader</groupId>
<artifactId>disthene-reader</artifactId>
<packaging>jar</packaging>
<version>2.0.11</version>
<version>2.0.12</version>
<name>disthene-reader</name>
<url>https://maven.apache.org</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private List<String> getPathsFromRegExs(String tenant, List<String> regExs, bool
String regEx = Joiner.on("|").skipNulls().join(regExs);

BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.regexpQuery("path.keyword", regEx))
.must(QueryBuilders.regexpQuery("path", regEx))
.filter(QueryBuilders.termQuery("tenant.keyword", tenant));

if (leaf) queryBuilder.filter(QueryBuilders.termQuery("leaf", true));
Expand Down Expand Up @@ -141,7 +141,7 @@ public String getPathsAsJsonArray(String tenant, String wildcard) throws TooMuch
}

BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.regexpQuery("path.keyword", regEx))
.must(QueryBuilders.regexpQuery("path", regEx))
.filter(QueryBuilders.termQuery("tenant.keyword", tenant));

SearchSourceBuilder sourceBuilder = new SearchSourceBuilder()
Expand Down Expand Up @@ -202,8 +202,8 @@ public String getPathsWithStats(String tenant, String wildcard) throws TooMuchDa

CountRequest countRequest = new CountRequest(indexConfiguration.getIndex())
.query(QueryBuilders.boolQuery()
.must(QueryBuilders.regexpQuery("path.keyword", path + "\\..*"))
.must(QueryBuilders.termQuery("tenant", tenant))
.must(QueryBuilders.regexpQuery("path", path + "\\..*"))
.must(QueryBuilders.termQuery("tenant.keyword", tenant))
.must(QueryBuilders.termQuery("leaf", true)));

CountResponse countResponse = client.count(countRequest, RequestOptions.DEFAULT);
Expand Down

0 comments on commit b961135

Please sign in to comment.