krisk / Fuse

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

Is there a way to assign priority to field/key? #331

Closed rampatra closed 5 years ago

rampatra commented 5 years ago

For example, I have a structure like:

{
   title: "Ram",
   body: "A very long string..."
}

So, here I want title to be given higher preference than body. Is this possible in the current version? If not, would this be a good feature to have?

rampatra commented 5 years ago

Too fast, found an example showing the very same thing. However, it would be nice to write about this under the "Set the options" heading.

Here is the example mentioned in the docs:

var options = {
  keys: [{
    name: 'title',
    weight: 0.3
  }, {
    name: 'author',
    weight: 0.7
  }]
};

Closing the issue now.

rampatra commented 5 years ago

Also, I assume the smaller the weight the higher the importance. Am I right?