krisk / Fuse

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

How can I know which key my search results came from? #267

Closed SoYoung210 closed 4 years ago

SoYoung210 commented 5 years ago

I would appreciate your understanding that my English is not great.

I have data

const mydata = [
  {
     "title" : "Blueberry Dream",
    "user" : {
         "username" : "kang"
      }
   },
   {
     "title" : "Swang",
    "user" : {
         "username" : "blueberry"
      }
    }
]

if i search keyword : blueberry the result would be mydata[0] and mydata[1]

mydata[0] is came from title , mydata[1] is came from username

can i know this? because, I want to sort the results like this.

Artists, Title, Lyrics ...

image

andru commented 5 years ago

Add includeMatches: true to the options. The key property of each entry in the match array shows the keypath matched against.

github-actions[bot] commented 4 years ago

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