Filter: Add IN[]
operator
#479
Replies: 10 comments 8 replies
-
Hey, great explanation. |
Beta Was this translation helpful? Give feedback.
-
Hey @loiclec! I have no particular opinion about the syntax personally. The main thing is that it is usable and solves the case of the user having to multiply the filter clauses which seems to be the case with the examples you give. Maybe the @meilisearch/integration-team will have a different opinion between Maybe it deserves another discussion about the position of the
|
Beta Was this translation helpful? Give feedback.
-
Just out of curiosity, would |
Beta Was this translation helpful? Give feedback.
-
NOT x IN [...] or X NOT IN [...] or bothI'm mot against the following as indeed @gmourier pointed out, it does make sense that it would work.
Nonetheless, it introduces double negations. Is there a use case where it would make sense that we use double negation? If we had to choose between one of them, Loic suggestion more in line with programming languages syntax // The ! is in front of the condition
if (!([1,2].includes(x)) {
// ...
} It also gives the possibility to create a list of conditions and ask form them all to be if (!([1,2].includes(x) || y = 2)) {
// ...
} Whereas SQL languages prefers adding the NOT after the fields name: SELECT Column(s) FROM table_name WHERE Column NOT IN (value1, value2... valueN); But it results in the case of multiple conditions being longer to express. The question is, do we want to go in the direction of SQL syntax or programming syntax? I'm not against accepting both. If I had to chose one I would go with @loiclec . Maybe we could do a poll? NOT x IN [...] or X NOT IN [...] or bothIn favor of |
Beta Was this translation helpful? Give feedback.
-
x IN [...] or x IN (...)(sorry for all the answers I try to separate every point that was brought) If we continue in the line of programming language this suggestion makes more sense to me:
If we want to go in the direction of SQL this one makes more sense.
I have a preference for the first option. Please vote with the appropriate emoji: In favor of This impacts the other poll: |
Beta Was this translation helpful? Give feedback.
-
x IN[...] or x IN [...]don't mind the bracket choice, this is another poll I don't like the
In favor of This impacts the other poll |
Beta Was this translation helpful? Give feedback.
-
Will this work with the inverse arrangement of parameters, such as The Documentation says:
and that
So I would assume not, but if this could be in consideration, that would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
-
Hello dear community, 👋 We have published a docker image allowing you to test the addition of the
|
Beta Was this translation helpful? Give feedback.
-
Hello 👋 We have just released v0.29.0rc1, which is a release candidate of v0.29.0 🔥 You can test the just-introduced Binaries are attached to the release, or you can use the docker image: docker run -it --rm \
-p 7700:7700 \
getmeili/meilisearch:v0.29.0rc1 Let us know about any bugs or feedback! 😄 It would be really helpful. FYI, the official v0.29.0 release will be available on 3rd October. |
Beta Was this translation helpful? Give feedback.
-
Hey everyone 👋 Locking this discussion since the
📚 https://docs.meilisearch.com/learn/advanced/filtering_and_faceted_search.html#using-filters Please open a new discussion if you have any feedback to share 🙇♂️ |
Beta Was this translation helpful? Give feedback.
-
Description
We had a few requests to add a
IN
filter which could provide a more efficient way to write filters containing too manyOR
orAND
. This would reduce the size of the request (in bytes) due to the syntax being terser and it would avoid running into filter complexity limits.Related discussions:
I propose the following syntax:
For example:
IN[...]
selects all documents whose attribute contains at least one of the values given inside the brackets. In case there are no values, then the filter selects no documents.NOT colour IN[...]
selects all documents with acolour
attribute which contains values that are all different from those in the brackets.I wrote a basic implementation of this filter on the branch
filter/field-in
of themilli
repo.Examples
With the following documents:
Here are a couple of examples of the ids that the filter would select:
The requirement that the attribute contains a value for the
NOT IN
filter can be considered surprising, but it follows from this equivalence:But someone could argue that
should behave differently or be disallowed.
Syntax details
I chose to use square brackets for the syntax instead of pqrentheses because parentheses are already used to group expressions together. Futhermore, square brackets denote lists in JSON and other programming languages, so it makes sense to use them here when we expect a list of values.
Trailing commas are allowed:
But a comma in an empty bracket pair is NOT allowed:
Other
Typesense also offers this functionality. From https://typesense.org/docs/0.22.2/api/documents.html#search-parameters :
The syntax is therefore similar but a colon is used instead of
IN
.Beta Was this translation helpful? Give feedback.
All reactions