I'm getting: `Could not find a field named `stores...
# community-help
e
I'm getting: `Could not find a field named
stores_count
in the schema for sorting` Do I need to set
facet: true
for sorting to work on that field?
k
No, sorting should be enabled for all numerical fields automatically. Can you please post your schema?
As long as it is defined in the schema.
e
message has been deleted
message has been deleted
oh wait, it should be defined in an array maybe?
k
How does it look on the document being indexed?
e
message has been deleted
k
🤔
e
OH wait! I'm sorry. I'm searching in multiple collections!
and the other collection doesn't have that field. DOH!
k
🙂 Okay
e
I need to use
collectionSpecificSearchParameters
👍 1
hmm, now the error is gone, but the sorting doesn't work, it's not sent with the request. I'm using the InstantSearch adapter (with Vue)
message has been deleted
message has been deleted
k
Should sortBy be an array?
Can you try:
sortBy: ['stores_count:desc']
If that doesn't work, @Jason Bosco will be able to help when he is around later.
e
yea, it didn't work. ok, thank you! you have a fantastic product! 🙂
🙌 2
j
@em1nos Are you looking to allow the user to sort, or will this be a fixed sort order?
e
well, i had the sort widget, but removed it thinking it was causing the issues .. but yes, I would like the end user to be able to sort .. I'm trying to set the default now
it seems the
collectionSpecificSearchParameters
doesn't work at all
message has been deleted
sorry, the above is not true
1 sec...
it just seems the "sort_by" is always an empty string
I don't know if I'm missing something, somewhere where I'm setting the sorting that's interfering with this
message has been deleted
j
Sorting is managed by instant search internally, you want to use the sort by widget this way: https://github.com/typesense/typesense-instantsearch-adapter#sortby
In Algolia, you’d create duplicate indices for each sort order, but in Typesense you can have multiple sort orders on the fly with one index. So you’d need to configure the sort by widget in a specific way to make it work with Typesense
e
ok, so setting a default sortBy in collectionSpecificSearchParameters will not work?
j
Correct. You can set a default sort order using the sort by widget
e
I see. OK. Thank you. I will try that! :)
but, what if I don't use the sorting widget? (I don't in the site-wide multi collection search/autocomplete)
j
I was just going to say, if you don’t want a user visible widget, then I think I need to add support for it for collectionSpecific search params. Looking at the code it currently only works for additional search parameters…
I’ll do this later today
e
sweet! 🙂
thank you so much
👍 1
j
@em1nos I've published a new version of the adapter that supports sortBy in collection specific parameters: https://www.npmjs.com/package/typesense-instantsearch-adapter/v/2.0.0-1
e
works! thank you!
🙌 1