Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the problem of Tag selector "=" filter can not match the whole word #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public StringQuery addMetricName(String value) {
}

public StringQuery addTagCond(String tagKey, String tagValExpr) {
String expr = "tags:" + tagKey + "=" + tagValExpr;
String expr = "tags.keyword:" + tagKey + "=" + tagValExpr;
valueExprs.add(expr);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testBuildQuery() {
System.out.println(qry);
Assert
.assertEquals(
"{\"size\":10000,\"query\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"tags:zone=G*\"}},{\"regexp\":{\"tags\":\"tags=.*ms\"}},{\"range\":{\"time\":{\"gte\":1556525226597,\"lte\":1556525226597,\"format\":\"epoch_millis\"}}}],\"must_not\":[{\"query_string\":{\"query\":\"tags:zone=G*\"}},{\"regexp\":{\"tags\":\"tags=.*ms\"}}]}}}",
"{\"size\":10000,\"query\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"tags.keyword:zone=G*\"}},{\"regexp\":{\"tags\":\"tags=.*ms\"}},{\"range\":{\"time\":{\"gte\":1556525226597,\"lte\":1556525226597,\"format\":\"epoch_millis\"}}}],\"must_not\":[{\"query_string\":{\"query\":\"tags.keyword:zone=G*\"}},{\"regexp\":{\"tags\":\"tags=.*ms\"}}]}}}",
qry);
}

Expand All @@ -52,7 +52,7 @@ public void testBuildQuery_no_mustnot() {
System.out.println(qry);
Assert
.assertEquals(
"{\"size\":10000,\"query\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"tags:zone=G*\"}},{\"regexp\":{\"tags\":\"tags=.*ms\"}},{\"range\":{\"time\":{\"gte\":1556525491882,\"lte\":1556525491882,\"format\":\"epoch_millis\"}}}],\"must_not\":[]}}}",
"{\"size\":10000,\"query\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"tags.keyword:zone=G*\"}},{\"regexp\":{\"tags\":\"tags=.*ms\"}},{\"range\":{\"time\":{\"gte\":1556525491882,\"lte\":1556525491882,\"format\":\"epoch_millis\"}}}],\"must_not\":[]}}}",
qry);
}

Expand All @@ -69,7 +69,7 @@ public void testBuildStringQuery() {
QueryBuilder.StringQuery stringQuery = new QueryBuilder.StringQuery();
stringQuery.addTagCond("zone", "G*").addTagCond("app", "zk");
System.out.println(stringQuery);
Assert.assertEquals("{\"query_string\":{\"query\":\"tags:zone=G* AND tags:app=zk\"}}",
Assert.assertEquals("{\"query_string\":{\"query\":\"tags.keyword:zone=G* AND tags.keyword:app=zk\"}}",
stringQuery.toString());

stringQuery = new QueryBuilder.StringQuery();
Expand Down