Description
Notice
Backstory: I've been migrating majority of heavy-duty queries from Doctrine ORM to Meilisearch.
Description
I would like to the possibility to be able to create filters that would allow the search
/ rawSearch
methods to have additional searchParams
/ options
from these filters.
Basic example
- The idea would be similar to Doctrine Filters, where an additional condition is added to the query when a filter is enabled.
- What I'm after is to create event listeners to add filters to seaches by default (also see this Symfony eventlistener example with Doctrine filters).
Other
An example use-case for this is as follows:
- Let's say I have authenticated and guest users.
- Both these types of users can perform searches on the same index, but the authenticated users can have access to more results.
- In order to achieve this, an additional field is added to the documents, e.g.
freeTier
.- The
freeTier = 1
is available for guests and authenticated users. - The
freeTier = 0
is explicitly available for authenticated users.
- The
- If the guest user seaches, it should add an additional filter to the
searchParams
which essentially would addAND (freeTier = 1)
filter. - If the authenticated user searches, it should not add this additional filter as authenticated users are allowed to search for both
freeTier
values0
and1
.
Now if similar, but not exact same, searches are performed on the same index, I'd still like it to take into consideration this freeTier = 1
field without manually concatenating this filter to every place a search on this index is performed. But with that in mind, if for some reason it is not desired to use the filter at a certain search, I should also have the possibility to disable/enable at any time.
The feature request boils down to a kind of Doctrine filters functionality for the Meilisearch search methods.