#community-help

Improved Sorting Options for Relevant Facets

TLDR Stefan proposes a feature for sorting facets based on other fields not just hit counts. Kishore Nallan agrees and emphasizes the need for the facet value to remain constant across different documents.

Powered by Struct AI
Nov 24, 2022 (13 months ago)
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
11:35 AM
What options do we currently have to show more relevant facets? I know that there is an open issue for that to sort facets, but is there anything I could do right now?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:39 AM
What do you mean by more relevant facets? Facets are sorted by count of hits.
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
11:45 AM
Yes, but I have a use case, where the count of hits is not that relevant, for example:

Imagine thousands of products where each product has 20 ingredients or so.

Almost all of them contain water, but that is pretty irrelevant.

I would like to show the ingredients in the default view that "make the difference" in a product.

Right now the only way I see on how to get those results is by creating a separate field in the schema that only contains the "relevant" ingredients.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:26 PM
Interesting. It almost feels like we need to introduce a way to sort the facets on some other field. But the thing is, the association between an ingredient to a specific recipe may not be captured simply by some popularity score. If that is possible, then having a sorting condition on faceting will help.
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
12:42 PM
Not sure if I get the last part correctly but sorting a facet based on another field is something that I also described in this issue: https://github.com/typesense/typesense/issues/521

So this feature would def. fix my issue.
12:42
Stefan
12:42 PM
*ingredients should be an array in this comment (fixed)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:52 PM
Would the calories value remain constant for all instances of that specific ingredient across different documents? If so, then this should be possible without any major rework.
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
12:53 PM
For my use case this would be the case
12:56
Stefan
12:56 PM
I think if that value wouldn't be static across ingredients then it wouldn't make much sense, because then two facets would mean two different things
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:03 PM
Correct, yes I think facet has to be constant.

Typesense

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

Indexed 3015 threads (79% resolved)

Join Our Community