Recommended way to boost based on a different field
amir20 opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Your question
Hello,
I think the closest issue I could find to this is #444. So I'd like to know if I am thinking about this the right way.
I use fuse.js for Dozzle where I show Docker logs. In the UI, users are able to search containers by name. So for example, data might look like
const data = [
{name: "foo bar", running: true},
{name: "foo bar", running: false},
{name: "test", running: true},
...
]
When searching for foo
I want containers that are running to be on top.
Currently, I do a custom sort after getting back the results from fuse. However, this is not super efficient because I have to receive more results than needed to do a proper sort.
But I wonder if there is a better way. I am familiar with Ellasticsearch and lucene. In those frameworks, I could do something like $query || ($query && running:true)^2)
where I am essentially boosting a second query to be at top.
What's the best way to achieve this?
Here are some ideas:
- Sort post search like I do now
- Use logical queries, but I am not sure how that would be possible because I don't want to specify every single field.
- Use an example like #444 and "boost" weight and resort
Any recommendation would be appreciated. Thank you!