react-instantsearch icon indicating copy to clipboard operation
react-instantsearch copied to clipboard

How to order or sort hits alphabetically in React Native

Open ragunaru opened this issue 8 years ago • 5 comments

Hi there,

After hours of searching all possible places, I am no closer to understanding how does one sort or order their returned hits in React Native.

I have set up the Configure widget like such:

<Configure filters='NOT venue_categories.name:"This"' />

The hits are returned by default in alphabetically descending order, I would like them to be in ascending order.

I would appreciate the help because the documentation just does not provide this simple piece of information.

ragunaru avatar Mar 29 '18 08:03 ragunaru

You can change that in the index settings, since it's related to how the index actually is searched. Your attribute in searchableAttributes either has unordered or descending set.

Did that help your issue?

Haroenv avatar Mar 29 '18 08:03 Haroenv

The attribute is set as ordered:

image

And there doesn't seem to be a way to change which way it orders (ASC or DESC).

ragunaru avatar Mar 29 '18 10:03 ragunaru

It seems I had to also add it to the ranking formula like such:

image

Solved now! Many thanks, @Haroenv! Closing the issue.

ragunaru avatar Mar 29 '18 10:03 ragunaru

Just as a follow up: I feel like this should be mentioned in the documentation somewhere, around query parameters and filters for the poor souls who, like me, go there to look for this.

ragunaru avatar Mar 29 '18 10:03 ragunaru

Ah yeah sorry, it indeed had to be changed in the ranking formula too. Thanks for this feedback. Lots of information is also in the main algolia.com/doc, don't forget to look there too :)

Haroenv avatar Mar 29 '18 11:03 Haroenv