shian
shian

Reputation: 124

result of searching in arrays of objects

I am using fuse.js to search in arrays of objects like http://fusejs.io/#searching-in-arrays-of-objects

It returns the whole item with the tag matched. How do I know which of the tags is matched?

Upvotes: 1

Views: 893

Answers (1)

Matt
Matt

Reputation: 4752

When you set your options, set verbose to true. This will log matching scores, with the matched key, to the console.

const options = {
  verbose: true,
  shouldSort: true,
  threshold: 0.6,
  location: 0,
  distance: 100,
  maxPatternLength: 32,
  minMatchCharLength: 1,
  keys: [
    "title",
    "author.firstName"
  ]
};
const fuse = new Fuse(list, options);

Upvotes: 0

Related Questions