#community-help

Querying MultiSearch with Typesense

TLDR Alex inquired about performing parallel multiSearch in Typesense, wanting to replicate an SQL query. Kishore Nallan informed them that multi_search executes parallel searches independently, and recommended using the filter_by clause. However, regular expressions and prefix search cannot be used in filters.

Powered by Struct AI

1

yw

1

Aug 09, 2022 (17 months ago)
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:14 PM
Typesense supports the multi query like query1 & query2 & query3...?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:15 PM
In filter_by clause? Can you please elaborate with an example?
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:16 PM
client.multiSearch.perform({
'searches': [
{
'q': 'North Carolina',
'query_by': 'state_name',
},
{
'q': 'Sanford',
'query_by': 'city',
}
]
}, queryParams: {
'collection': 'report_header'
}).then((values) {
values.entries.forEach((element) {
print(element);
});
}).catchError((error) {
print(error);
});;
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:17 PM
Got it. No, the queries in multi_search are executed in-parallel independently. There's no way to do an AND of them.
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:18 PM
I want to get results where state_name='North Carolina' and city='Sanford' like sql query
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:19 PM
For that you can set q=* and use the filter_by clause which supports the && operator.
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:19 PM
Thanks
yw

1

Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:19 PM
state_name: North Carolina && city: Sandord will work

1

Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:34 PM
Filter can include regular expression?
for example , state_name: Nort && city: san
result state: North city: Sanford
02:35
Alex
02:35 PM
I want to get all results that String.contains(query String)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:38 PM
Filter does not support regexp. Filtering by default already works in contains mode.
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:39 PM
{
'q': 'North',
'query_by': 'order.appointment_address.state_name',
'filter_by': 'order.appointment_address.city: Sanfor',
},
02:40
Alex
02:40 PM
it is not working
02:40
Alex
02:40 PM
'filter_by': 'order.appointment_address.city: Sanford',
02:40
Alex
02:40 PM
This is working correclty
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:46 PM
Filter does not do prefix search. When I mean by string contains, I mean at the word level not char level
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
02:47 PM
Then, How can I do multi prefix search?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:06 PM
That's not possible.
03:08
Kishore Nallan
03:08 PM
Did you try q=North Carolina Sanford with query_by=state_name,city?
Alex
Photo of md5-d9ca032e3941589aafa8433269974f96
Alex
04:39 PM
Then, result is query1 || query2
04:40
Alex
04:40 PM
I want query1 && query2
Aug 10, 2022 (17 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:42 AM
If there is a record that contains all words North Carolina Sanford then that record will be returned first. That's not enough?

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community