algoliasearch-rails icon indicating copy to clipboard operation
algoliasearch-rails copied to clipboard

How to set a sort-by attribute?

Open corbt opened this issue 7 years ago • 3 comments

Using the customRanking option, I'm able to add attributes to rank by to break ties in the textual relevance. However, I'm not able to add attributes to sort by BEFORE applying textual relevance (the green "SORT-BY" field in the web UI below). How can I go about adding those with the algolia-rails gem? Thanks!

screen shot 2018-02-09 at 4 46 10 pm

corbt avatar Feb 10 '18 00:02 corbt

I'm also trying to do that, did you find a way?

Spone avatar May 15 '18 20:05 Spone

are you looking for this? https://github.com/algolia/algoliasearch-rails/issues/237

jinsoocha avatar Aug 17 '18 17:08 jinsoocha

Thanks @jinsoocha

Maybe there could be a shortcut for the configuration, something like:

algoliasearch ... do
  # ....
  sortBy 'asc(start_datetime_i)'
end

that could be the same as doing:

algoliasearch ... do
  # ....
  ranking ['asc(start_datetime_i)', 'typo', 'geo', 'words', 'filters', 'proximity', 'attribute', 'exact', 'custom']
end

Spone avatar May 08 '19 16:05 Spone