Is custom sorting on search not supported?
See original GitHub issueThe Custom sort seems to only sort the results.
I have 10,000 documents indexed and I search with a limit of 10 and those 10 are now sorted according to popularity
. I’m doing:
const indexResults = this.index.search({
query: q,
field: "title",
limit: 10,
sort: (a, b) => b.popularity - a.popularity,
suggest: true
});
But it still seems to sort on “matchness” (or “relevance”) and NOT on my popularity
.
What I want, when I type wa
that the document that contains a wa
anywhere and has the highest popularity
should appear first. If there are, 10,000 documents and 1,000 that technically match wa
I want those 1,000 to be sorted by popularity
.
(PS. I tried using sort: "popularity"
but that sorted the results the wrong direction and doing sort: "-popularity"
didn’t work)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Custom Sort not Working - Microsoft Community Hub
In the sample file the custom sort works according to the settings. The data for year 2006 is sorted in ascending order and...
Read more >Activity Custom Lookups do not support Sort options, but they ...
When Activity Custom Lookups are turned on and add a lookup to a custom object, the resulting related list has the option to...
Read more >Sorting and filtering is not working in google custom search ...
Q) if I use sort by attribute date-sdate and pages which doesn't have this attribute should not appear in search results right because...
Read more >Custom Sorting option not working in Magetno 2.4 search
When i select the Newest filter it shows the message No Result Found. Any one tell me what is the issue or any...
Read more >Log sorting - Custom sorting is not working - Stack Overflow
It's not a sorted array, so that you can just go from one element to the one with the lesser priority.The Iterator provided...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually. I tried that. It works really well! Here’s what I did:
Doing a couple of searches this way seems to produce pretty good results. At least good enough that I’m no longer blocked and can continue to use FlexSearch.
Yeah nice idea. It works when the results have the same relevance. If not the relevance gets prioritize over the sort. But you can control relevance. Relevance isn’t a float value, it is an integer. You can control the “resolution” of how many different relevance values exist (“slots”). This way you can force to sort by an external value regardless of the relevance:
This will categorize each text to the same relevance “slot”.