How to search by multiple fields on django_opensearch_dsl
I have an opensearch server in which I want to search items and apply some filters to the search:
search = Item.search().query("match", name="test")
I need to search items by multiple filters, like name, date, location, etc. For this I will need some other kind of queries like "range" or "terms".
Now the issue is I've trying using opensearch-dsl
package like this:
search_1 = ESQ("match", name="test")
search_2 = ESQ("terms", name="location")
search_3 = ESQ("range", name="date")
filters = [search_1, search_2, search_3]
query = ESQ("bool", should=filters)
search = FreezerItemDocument.search().query(query)
This is not working, constantly returning errors like:
{"error":"unhashable type: 'Bool'"}
Event if I try to run the query individually like this:
query = ESQ("match", name="test")
search = FreezerItemDocument.search().query(query)
How can I do a search by multiple fields?