#community-help

Query Filtering and Relevant Search Functionality

TLDR em1nos inquired about filtering query support akin to "must have this" or "-not -these" and received clarification from Jason. em1nos then discussed issues with extracting relevant Store Products, to which Jason suggested specific attribute-based searching and weighting.

Powered by Struct AI
+12
heavy_plus_sign1
18
26mo
Solved
Join the chat
Jul 23, 2021 (26 months ago)
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
07:37 PM
is there any support for some kind of "filtering" in the actual query, like forcing a token with quotes "must have this", or must not have a token with -not -these ? things like that?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:37 PM
-not -these is supported.

"must have this" (called phrase search) is not yet supported.
+11
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
07:38 PM
that's it? no other ones?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:39 PM
That's it at the moment. What others do you have in mind?
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
07:40 PM
I'm not sure honestly. Let me explain what I'm trying to do (might not be related to these things)...
heavy_plus_sign1
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:40 PM
Could you thumbs up this issue for phrase query: https://github.com/typesense/typesense/issues/272
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
07:43 PM
So. I have two collections. Products and Store Products.
I need to run some kind of intelligent search on a Product name, to find a bunch of very relevant Store Products. (to attach them to the Product)

this might be irrelevant for you, but just for context ...
07:43
em1nos
07:43 PM
Products are Mobile Phones (for now).
Store Products can be anything.
07:44
em1nos
07:44 PM
Example Product name: Samsung Galaxy A72 256GB (8GB RAM)
07:45
em1nos
07:45 PM
which when searching the Store Products collection, with the default settings, also finds a bunch of very irrelevant Store Products. Lenovo laptops with 8GB or RAM ... things like that.
07:45
em1nos
07:45 PM
I'm playing around with the settings to exclude most of the irrelevant Store Products
07:46
em1nos
07:46 PM
07:46
em1nos
07:46 PM
I don't know if I'm missing something. Maybe you have some tip to give me?
07:47
em1nos
07:47 PM
Or is that it? I just have to play around with these settings to try to get to most relevancy possible?
07:51
em1nos
07:51 PM
for example, in the search query "Samsung Galaxy A72 256GB (8GB RAM)", some tokens (words?) are more important than others. A72 is super important to find the correct phone. While 256GB and 8GB RAM is not, since not all Store Product names will even have those in the name.
07:52
em1nos
07:52 PM
also, can I use the text_match score in some way, to find (perfect) relevancy?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:35 PM
Ah model numbers... One thing I'd recommend is to store Brand, Make, Model, Capacity, etc in distinct attributes in the document.

Then when searching, you could turn off typo tolerance just for Model Number and Capacity. You could also turn off prefix search if you prefer that.

You'd then also be able to weight Brand and Model higher than capacity for eg using query_by_weights
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
08:58 PM
thank you so much!
+11