Fuse: In the search result, what is refIndex?

Created on 14 Apr 2020  路  4Comments  路  Source: krisk/Fuse

When I have the option findAllMatches set to true, it lists out all the matches in the matches array.

For example, Searching "Apple"
Result in an array of 3 objects.
1. What is the refIndex for?

object1:
{item: {...}, refInfex: 72, matches: Array(2), score: 0.002}

object2:
{item: {...}, refInfex: 38, matches: Array(1), score: 0.0024}

object3:
{item: {...}, refInfex: 88, matches: Array(3), score: 0.003}

And if we expand to see the matches in one of the objects
2. What is the refIndex in match for?

matches: [
    {indices: Array(1), value: "Apple", key: "name", refIndex: 0}
    {indices: Array(1), value: "Apple pie", key: "product"}
]

3. Would it make more sense to provide score for each of the matches??
for example

matches: [
    {indices: Array(1), value: "Apple", key: "fruit", refIndex: 0, score: 0}
    {indices: Array(1), value: "Apple pie", key: "product", score: 0.001}
]

that way we know that "fruit" key has the highest matching score.

question

Most helpful comment

refIndex corresponds to the match's index in the original list (or nested array). For example, suppose you have the following list:

const list = [{
  "name": "Two",
  "tags": ["one", "two", "three"]
}]

And you search "name", and "tags", and you search for "two", Fuse would return the index of the item in list (refIndex:0), as well as the index of the matched tag in the nested array (refIndex:1).

All 4 comments

...and is there a way to return to the results from version 2?

...and is there a way to return to the results from version 2?

what is version 2 referring to?

refIndex corresponds to the match's index in the original list (or nested array). For example, suppose you have the following list:

const list = [{
  "name": "Two",
  "tags": ["one", "two", "three"]
}]

And you search "name", and "tags", and you search for "two", Fuse would return the index of the item in list (refIndex:0), as well as the index of the matched tag in the nested array (refIndex:1).

refIndex corresponds to the match's index in the original list (or nested array). For example, suppose you have the following list:

const list = [{
  "name": "Two",
  "tags": ["one", "two", "three"]
}]

And you search "name", and "tags", and you search for "two", Fuse would return the index of the item in list (refIndex:0), as well as the index of the matched tag in the nested array (refIndex:1).

I see that makes sense! Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robertsass picture robertsass  路  3Comments

ibraheemdev picture ibraheemdev  路  3Comments

312307025 picture 312307025  路  4Comments

cekvenich picture cekvenich  路  4Comments

danitrod picture danitrod  路  4Comments