I have a list of objects I need to search through. I have different weights for matches in different properties of the object. For example, this is my full search configuration:
const FUSE_OPTIONS = {
isCaseSensitive: false,
includeScore: true, // return the score alongside the match (lower is better)
includeMatches: true, // return the match indices so that the matched portions can be highlighted
findAllMatches: true, // if multiple matches exist, then that object should have a better score
minMatchCharLength: 1,
ignoreLocation: true, // it should not matter where in the search string the pattern appears
ignoreFieldNorm: true,
threshold: 0.5, // allow fuzzy matches
keys: [
{ name: 'snippet.shortcut', weight: 4 },
{ name: 'snippet.name', weight: 3 },
{ name: 'group', weight: 2 },
{ name: 'text', weight: 1 },
]
};
Right now, this configuration has an issue. Fuzzy matches from 'snippet.shortcut' rank higher than exact matches from 'text' property, because of the disproportionate weight.
In the search result list, I want the exact matches to show up first in the results. After that, I want to show the fuzzy matches. In other words, the search results list can be divided into two sections:
[list start][exact matches sorted by total weight][fuzzy matches sorted by total weight][list end]
Is this possible to do directly in fuse.js? I guess it's possible for me to do this manually by running fuse.js twice and manually extracting out the exact matches in the first call, but it's very cumbersome.
I have a list of objects I need to search through. I have different weights for matches in different properties of the object. For example, this is my full search configuration:
Right now, this configuration has an issue. Fuzzy matches from
'snippet.shortcut'
rank higher than exact matches from'text'
property, because of the disproportionate weight.In the search result list, I want the exact matches to show up first in the results. After that, I want to show the fuzzy matches. In other words, the search results list can be divided into two sections:
[list start][exact matches sorted by total weight][fuzzy matches sorted by total weight][list end]
Is this possible to do directly in fuse.js? I guess it's possible for me to do this manually by running fuse.js twice and manually extracting out the exact matches in the first call, but it's very cumbersome.