krisk / Fuse

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

About the criteria for measuring the score #566

Closed xpdlf1004 closed 2 years ago

xpdlf1004 commented 2 years ago

list.json

[
  {
    "title": "ㅇㅐㅍㅡㄹ MacBook Air 13ㅎㅕㅇ 2020ㄴㅕㄴ M1 CPU 8ㅋㅗㅇㅓ GPU 8ㅋㅗㅇㅓ 512GB ㄱㅗㄹㄷㅡ"
  },
  {
    "title": "ㅇㅐㅍㅡㄹ MacBook Air 13ㅎㅕㅇ 2020ㄴㅕㄴ M1 CPU 8ㅋㅗㅇㅓ GPU 7ㅋㅗㅇㅓ 256GB ㅅㅡㅍㅔㅇㅣㅅㅡ ㄱㅡㄹㅔㅇㅣ"
  }
]

input

MacBook Air 13 256GB

result

[
  {
    "item": {
      "title": "ㅇㅐㅍㅡㄹ MacBook Air 13ㅎㅕㅇ 2020ㄴㅕㄴ M1 CPU 8ㅋㅗㅇㅓ GPU 8ㅋㅗㅇㅓ 512GB ㄱㅗㄹㄷㅡ"
    },
    "refIndex": 0,
    "matches": [
      {
        "indices": [[5, 17], [23, 24], [26, 26], [31, 32], [34, 35], [38, 38], [44, 45], [48, 48], [54, 55], [57, 60]],
        "value": "Mㅇㅐㅍㅡㄹ MacBook Air 13ㅎㅕㅇ 2020ㄴㅕㄴ M1 CPU 8ㅋㅗㅇㅓ GPU 8ㅋㅗㅇㅓ 512GB ㄱㅗㄹㄷㅡ",
        "key": "title"
      }
    ],
    "score": 0.7689796321908181
  },
  {
    "item": {
      "title": "ㅇㅐㅍㅡㄹ MacBook Air 13ㅎㅕㅇ 2020ㄴㅕㄴ M1 CPU 8ㅋㅗㅇㅓ GPU 7ㅋㅗㅇㅓ 256GB ㅅㅡㅍㅔㅇㅣㅅㅡ ㄱㅡㄹㅔㅇㅣ"
    },
    "refIndex": 1,
    "matches": [
      {
        "indices": [[5, 17], [23, 24], [26, 26], [31, 32], [34, 35], [38, 38], [44, 45], [48, 48], [54, 60], [69, 69]],
        "value": "ㅇㅐㅍㅡㄹ MacBook Air 13ㅎㅕㅇ 2020ㄴㅕㄴ M1 CPU 8ㅋㅗㅇㅓ GPU 7ㅋㅗㅇㅓ 256GB ㅅㅡㅍㅔㅇㅣㅅㅡ ㄱㅡㄹㅔㅇㅣ",
        "key": "title"
      }
    ],
    "score": 0.7774132477399261
  }
]

In the above case, the second item with an exact match of 256GB should have a higher score, so why does 512GB have a higher score?

xpdlf1004 commented 2 years ago

Oh.. I figure out that length equality affects the score.!

I solved it by adding ignoreFieldNorm: true option. Thanks!

github-actions[bot] commented 2 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