-
Notifications
You must be signed in to change notification settings - Fork 227
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(query) Regex equals .* must ignore the label and match series even without the label #1639
Conversation
…n without the label
…n without the label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good (and thanks for the tests btw) 👍
private def leafFilter(column: String, filter: Filter): Query = { | ||
filter match { | ||
case EqualsRegex(value) => | ||
val regex = removeRegexAnchors(value.toString) | ||
if (regex.nonEmpty) new RegexpQuery(new Term(column, regex), RegExp.NONE) | ||
else leafFilter(column, NotEqualsRegex(".+")) // value="" means the label is absent or has an empty value. | ||
if(regex.r.unapplySeq("").isDefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: does matches
work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what I was looking for, but its available in Scala 2.13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I can do this regex.r.pattern.matcher("").matches()
since regex does not provide the matches
method
// Check if the given regex matches the empty string, if yes, then do not consider this label | ||
val booleanQuery = new BooleanQuery.Builder | ||
val allDocs = new MatchAllDocsQuery | ||
booleanQuery.add(allDocs, Occur.FILTER).build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just return a MatchAllDocsQuery
directly (it implements Query
, at least.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, done
…n without the label
…n without the label
…n without the label
Pull Request checklist
Current behavior :
Queries like
foo{dummy=~".*"}
are expected to match all timeseries with metric name foo even without the label dummy, in short, the filter should have same behavior as not having the filter. However, currently the matches are only made for series with the label presentNew behavior :
The above behavior is fixed and now the label is not considered in matching if it matches an empty string
""