-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
http://example.com/ba*,-bar,-baz/_search will search over index foo #3839
Comments
There's a related issue. I'm looking at implementing an authorization model by appending a list of indexes or aliases that the user shouldn't see to the user request. So, if the user requests an index that they shouldn't then the logic strips it out again. Alternate solutions are welcome. Within that context, a request for http://example.com/foo,-foo/_search makes sense. Unfortunately, this doesn't work. When MetaData.convertFromWildcards() encounters a -foo, it will either: So, foo,-foo returns an exception saying that it can't find an index called -foo. Instead, I would propose that a non-first minus term will populate the results set with all previous entries encountered. This logic is also used when processing a wildcard expression to resolve the expression "foo,ba*". |
The first issue has been fixed, the issue from the second comment is still valid:
|
And, this searches all indices including bar and baz:
While this search all indices except bar and baz:
|
I was able to reproduce this on latest master with the following:
Took a quick look at the code... l'll make a PR shortly with the fix. @clintongormley While I was investigating this I noticed the following request resulted in a similar error:
However this error is slightly different than with
This is the same error as with |
Would the indices be resolved differently if the I tried removing all the |
…crete index followed by an add/remove concrete index. The code now properly adds/removes the index instead of throwing an exception. Closes elastic#3839
…crete index followed by an add/remove concrete index. The code now properly adds/removes the index instead of throwing an exception. Closes elastic#3839
…crete index followed by an add/remove concrete index. The code now properly adds/removes the index instead of throwing an exception. Closes elastic#3839
…crete index followed by an add/remove concrete index. The code now properly adds/removes the index instead of throwing an exception. Closes elastic#3839
There still seems to be a problem here. When I run the following query it won't work. But if I switch the position of the indices it works. It seems the - sign is not interpreted correctly as in following example. This is for version 5.0.2 |
Create three indexes: foo, bar, and baz.
Submit a search request using the URL: http://example.com/ba*,-bar,-baz/_search. This performs a search over all indices.
The logic of the MetaData.convertFromWildcards() method is as follows:
First token is ba* - expand that into bar and baz and add them to the result set.
Second token is a negation of bar so it removes that.
Third token is a negation of baz so it removes that to leave an empty set.
The problem is that an empty index set is also generated by http://example.com/_search.
There is later logic in PlainOperationRouting.computeTargetedShards() that treats the empty set as a request to search every index, including the index foo and the two indices that have been explicitly removed.
The proposed solution is:
The text was updated successfully, but these errors were encountered: