-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Filters parameter can not be empty string #1338
Comments
$ curl -X POST http://localhost:7700/indexes/indexUID/search --data '{ "q": "", "filters": "" }'
{"message":"error parsing filter; --> 1:1\n |\n1 | \n | ^---\n |\n = expected other","errorCode":"invalid_filter","errorType":"invalid_request_error","errorLink":"https://docs.meilisearch.com/errors#invalid_filter"}⏎ MeiliSearch version: 0.20.0 |
Checked with @gmourier This will be fixed in next versions |
Fixed in v0.25.0rc0 Test:
[
{ "id": 2, "title": "Pride and Prejudice", "author": "Jane Austin", "genre": "romance", "price": 3.5 },
{ "id": 456, "title": "Le Petit Prince", "author": "Antoine de Saint-Exupéry", "genre": "adventure" , "price": 10.0 },
{ "id": 1, "title": "Alice In Wonderland", "author": "Lewis Carroll", "genre": "fantasy", "price": 25.99 },
{ "id": 1344, "title": "The Hobbit", "author": "J. R. R. Tolkien", "genre": "fantasy" },
{ "id": 4, "title": "Harry Potter and the Half-Blood Prince", "author": "J. K. Rowling", "genre": "fantasy" },
{ "id": 42, "title": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams" }
]
{
"q": "",
"filter": ""
} {
"hits": [],
"nbHits": 0,
"exhaustiveNbHits": false,
"query": "",
"limit": 20,
"offset": 0,
"processingTimeMs": 2
} |
An empty filter gives returns no hits? Since there is no filter condition in the string, it should not apply any filter. With the same logic, an empty query should also return no documents. Also implementation wise, if you create dynamically your filters you'll have to check if Maybe I should answer to that in the related specification? |
Discussion about what we need to do here meilisearch/milli#422 |
422: Prefer returning `None` instead of using an `FilterCondition::Empty` state r=Kerollmops a=Kerollmops This PR is related to the issue comment meilisearch/meilisearch#1338 (comment) which exhibits the fact that when a filter is known to be empty no results are returned which is wrong, the filter should not apply as no restriction is done on the documents set. The filter system on the milli side has introduced an Empty state which was used in this kind of situation but I found out that it is not needed and that when we parse a filter and that it is empty we can simply return `None` as the `Filter::from_array` constructor does. So I removed it and added tests! On the MeiliSearch side, we just need to match on a `None` and completely ignore the filter in such a case. Co-authored-by: Clément Renault <clement@meilisearch.com>
Describe the bug
When trying to do a search with an empty string an error is thrown. The error message is also not really clear.
To Reproduce
Steps to reproduce the behavior:
filters: ""
as a search parameterExpected behavior
Ignore the empty filter as no filter is still a filter.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: