-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Only negate index expression on all indices with preceding wildcard #20898
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
Changes from all commits
5d54c70
a7f4af5
5a2df4e
7453fc5
e4d5ee2
12b957b
5f186a9
6982a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -579,6 +579,7 @@ public List<String> resolve(Context context, List<String> expressions) { | |
|
|
||
| private Set<String> innerResolve(Context context, List<String> expressions, IndicesOptions options, MetaData metaData) { | ||
| Set<String> result = null; | ||
| boolean wildcardSeen = false; | ||
| for (int i = 0; i < expressions.size(); i++) { | ||
| String expression = expressions.get(i); | ||
| if (aliasOrIndexExists(metaData, expression)) { | ||
|
|
@@ -598,13 +599,14 @@ private Set<String> innerResolve(Context context, List<String> expressions, Indi | |
| } | ||
| expression = expression.substring(1); | ||
| } else if (expression.charAt(0) == '-') { | ||
| // if its the first, fill it with all the indices... | ||
| if (i == 0) { | ||
| List<String> concreteIndices = resolveEmptyOrTrivialWildcard(options, metaData, false); | ||
| result = new HashSet<>(concreteIndices); | ||
| // if there is a negation without a wildcard being previously seen, add it verbatim, | ||
| // otherwise return the expression | ||
| if (wildcardSeen) { | ||
| add = false; | ||
| expression = expression.substring(1); | ||
| } else { | ||
| add = true; | ||
| } | ||
| add = false; | ||
| expression = expression.substring(1); | ||
| } | ||
| if (result == null) { | ||
| // add all the previous ones... | ||
|
|
@@ -634,6 +636,10 @@ private Set<String> innerResolve(Context context, List<String> expressions, Indi | |
| if (!noIndicesAllowedOrMatches(options, matches)) { | ||
| throw infe(expression); | ||
| } | ||
|
|
||
| if (Regex.isSimpleMatchPattern(expression)) { | ||
| wildcardSeen = true; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should set this to true only if options.expandWildcardsOpen || options.expandWildcardsClosed . Otherwise wildcard expressions don't get expanded...
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, I've changed the |
||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
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.
do you understand this if block? I suspect it made sense before your change, to make it possible to refer to existing indices or aliases that started with
-rather than treating the name as a negation. That said, I can't quite follow why it makes sense in some cases forresultto benull. This was already there, not your doing but I wonder if it's related and may be cleaned up.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 don't know why it doesn't initialize the
resultset like the other null checks do, but I do think all of this code should be cleaned up after this (I hesitate to touch more code as this is supposed to be backported all the way back to 2.4)