Reputation: 456
In Flutter, I'm trying to query my Typesense messages collection. I'd like to return all the messages that have message_from="abc" OR message_to="abc". Instead, in the example below, it only returns messages with message_from="abc". Could you please help? Thanks
The query below only returns
params = {
'searches': [
{
"query_by": "message_from",
'filter_by': 'message_from:abc',
},
{
"query_by": "message_to",
'filter_by': 'message_to:abc',
}
],
};
final commonSearchParams = {
'q': '*',
'collection': 'messages',
'page': page.toString(),
'per_page': perPage.toString(),
'group_by': 'thread',
'sort_by': 'date:desc',
};
return typesenseClient.multiSearch
.perform(params!, queryParams: commonSearchParams)
.then((docs) {
return docs["results"][0]["grouped_hits"];
});
Upvotes: 2
Views: 1964
Reputation: 2193
According to the documentation, filter_by OR conditions on the same field are in array notation, accros different fields with the ||
operator :
message_from: abc || message_to: abc
or, if you want exact matches:
message_from:= abc || message_to:= abc
Upvotes: 0
Reputation: 8225
You can accomplish this with comma-separated fields instead of using multi-search. I.e. {query_by: "message_from,message_to", ...}
.
Upvotes: 1