Open
Description
Description
It would be nice to provide a class like Meilisearch::FilterBuilder
that converts Ruby hashes/arrays to Meilisearch filter expressions.
I already did that in one of my projects and it provides a huge added value. I just get the params from the request, build the hash, then pass it to the builder.
The question is, will you be open to upstream the implementation of my builder into the gem? Or should I extract the class to my own gem ?,? (Any naming suggestions in this case 😅)
Basic example
Example 1
Ruby object:
or: [
{ genres: 'horror' },
{ and: [
{ genres: 'comedy' },
{ release_date: { gt: 795_484_800 } }
] }
]
Meilisearch filter expressions:
genres = horror OR (genres = comedy AND release_date > 795484800)
Example 2
Ruby object:
{ genres: 'horror', director: 'Jordan Peele' }
Meilisearch filter expressions:
genres = horror AND director = 'Jordan Peele'
Example 3
Ruby object:
{ not: { genres: { in: %w[horror comedy] } } }
Meilisearch filter expressions:
NOT (genres IN [horror, comedy])
Other
I have the implementation and the specs for it, but I'm not sure about publishing a PR to this gem, or extract it to my own gem.