FuzzySearch icon indicating copy to clipboard operation
FuzzySearch copied to clipboard

Highlight exact search query

Open goliney opened this issue 5 years ago • 1 comments

Characters that are not present in a search query get highlighted:

Code

import FuzzySearch from 'fz-search'; // v1.0.0

const nodes = [
  {
    value: 'primer'
  },
];

const fuzzy = new FuzzySearch({
  source: nodes,
  keys: 'value',
});
  
const [result] = fuzzy.search('pre').map(
  item => fuzzy.highlight(item.value)
);

console.log(result);

Actual result

<strong class="highlight">prime</strong>r

primer

Expected result

<strong class="highlight">pr</strong>im<strong class="highlight">e</strong>r

primer

Problem

As you can see, symbols im aren't present in a search query, but they are still highlighted.

Is it possible to avoid highlighting of symbols that are not present in a search query?

goliney avatar Aug 05 '19 21:08 goliney

Sorry for late reply. Gap filling is a feature for less tech savy that prefer word and word-part than bag of letters. However it's optional, set this to 0:

highlight_bridge_gap: 0, // default 2

jeancroy avatar Sep 11 '19 15:09 jeancroy