Make `with_filter` work also with the array syntax
Closed this issue · 3 comments
In v0.21.0, the with_filter
function corresponding to the filter
search parameter can accept both array and string syntax:
- string:
"filter": "genre = comedy AND price > 13"
- array:
"filter": ["genre = comedy", "price > 13"]
Currently, only the string syntax is accepted:
index
.search()
.with_filter("value = \"The Social Network\" AND price < 3")
.execute()
.await
with_filter
should accept both syntaxes, or another function allowing the array syntax should be added- tests must be added
hey @curquiza , I would like to work on this issue.
This might be a silly question but can you please answer it for me as this is my first contribution :) ?
I think that I need to add some other function ( such as with_array_filter
? ) and then can connect the items into a string and pass them through the original with_filter
function and write some basic tests to ensure that it connects all of them properly?
hey @curquiza , I would like to work on this issue.
This might be a silly question but can you please answer it for me as this is my first contribution :) ?
I think that I need to add some other function ( such as
with_array_filter
? ) and then can connect the items into a string and pass them through the originalwith_filter
function and write some basic tests to ensure that it connects all of them properly?
That won't work due to lifetimes. with_filter
takes a &str
. What you can do is adding a new array_filters
field on the struct (and the setter function of course).
Edit: oh no we are using serde on this. You have to create an enum that can store both filter types without creating the new field. And you have to make serde serialize and deserialize this without the variant name. Maybe that would require implementing serde's functions by hand. This is a great exercise though
Hello @heksadecimal and @Mubelotix!
Thanks @Mubelotix for your explanation. Feel free to open a PR @heksadecimal following the @Mubelotix's instructions :)