krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.76k stars 753 forks source link

how to search for a complete word (instead of query beeing included in another word)? #676

Closed Thomas-1985 closed 1 year ago

Thomas-1985 commented 1 year ago

Hi

version: 6.6.2

Example data:

var data = [
  {
    "title": "Old Man's War",
    "author": "John Scalzi"
  },
  {
    "title": "The Lock Artist",
    "author": "Steve"
  },
  {
    "title": "Artist for Life",
    "author": "Michelangelo"
  },
  {
    "title": "Artists for Life",
    "author": "Michelangelo"
  }
];

If i use the following, i get the last two results of above

    const searchOptions = {
      includeScore: false,
      ignoreLocation: true,
      useExtendedSearch: true,
      keys: ['title']
    }

    const fuse = new Fuse(data, searchOptions)
    const searchResult = fuse.search(`'Artist`);

What i need (and i don't know how to acomplish that) is that the result is only returned, if the keyword matches a whole word (regardless if the key holds one or many words). So in the above example, only the second and the third results should be returned.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days