typesense icon indicating copy to clipboard operation
typesense copied to clipboard

[NEW Feature]Sorting facets alphabetically

Open drigolin opened this issue 4 years ago • 2 comments

I would like to suggest to add support for sort facets returned alphabetically and not only by frequency as in solr or elastic. A parameter like facet_sort_by: freq or apha and having desc/ asc as option as we have for sort_by

Thank you

drigolin avatar Feb 10 '22 11:02 drigolin

@drigolin This is a good suggestion. We will add to our roadmap.

kishorenc avatar Feb 11 '22 06:02 kishorenc

Any news on this feature?

aspectiscool avatar Jul 07 '22 01:07 aspectiscool

I also came here to suggest this same and found this thread.

This would be well received and its possibly a minor change on TS side. Of course, this can be done client side before display, but that's a bit fiddly and its possible more elegant to just get it in the API.

zehawki avatar Oct 16 '22 10:10 zehawki

I would like to add the following idea:

Assume we are faceting for a nested fields, it would be great if we could sort by another value of that nested field for example:

ingredients: [{ "name": "Chicken", "calories": 100 }]

If we could sort ingredients.name by ingredients.calories that would be amazing.

This way we could show more relevant results for a facet like:

"Exclude high calorie ingredients"

reinoldus avatar Nov 22 '22 13:11 reinoldus

Both alpha sorting and sorting facets on the value of another field available on 0.26.0.rc20. Usage:

Sorting alphabetically:

"facet_by": "phone(sort_by: _alpha:asc)"

Sorting facets by another field's value:

Given an object like this:

{
  "id": "0",
  "recipe": {
    "name": "pizza",
    "calories": 270
  }
}

You can sort the facet values for recipe.name by the calories this way:

"facet_by": "recipe.name(sort_by: recipe.calories:asc)"

kishorenc avatar Sep 25 '23 14:09 kishorenc

Thank you! Waiting for release in the cloud.

egorkel-altexsoft avatar Mar 26 '24 16:03 egorkel-altexsoft

You can already use it in Typesense Cloud, by going to Cluster Configuration > Modify and picking the latest 0.26.0.rc at the bottom of the Version dropdown.

jasonbosco avatar Mar 26 '24 16:03 jasonbosco

Released in v26

jasonbosco avatar Apr 02 '24 21:04 jasonbosco