Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect refIndex #785

Open
1 task done
Taliss opened this issue Nov 15, 2024 · 3 comments
Open
1 task done

Incorrect refIndex #785

Taliss opened this issue Nov 15, 2024 · 3 comments
Labels

Comments

@Taliss
Copy link

Taliss commented Nov 15, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

Hello there and thank you for the great lib.

I have the following scenario using fuse v7.0.0 ( not able to select it in the template );
The returned nested refIndex in matches doesn't look to be zero-based.

Here is a single item from my data set:

    title: 'Most popular functions and keywords',
    name: 'most-popular',
    subSections: [
      {
        name:'parentsOfIssuesInQuery',
        description: 'Find the parents of the issues returned from the subquery (defined in parentheses).',
        examples: [
          {
            note: "Find all the parents of epics in my ACME project:",
            snippet: [`issue in parentsOfIssuesInQuery("project='ACME' and type=Epic")`]
          }]
      },
       {
          name:'linkedIssuesOfQuery',
          description: 'Find issues linked to the issues returned from the subquery (defined in parentheses).',
          examples: [
            {
              note: "Finds issues that block my project ACME:",
              snippet: [`issue in linkedIssuesOfQuery("project=ACME", "is blocked by")`],
            },
            {
              note: "Finds issues that are linked with epics that are in To Do:",
              snippet: [`issue in linkedIssuesOfQuery("type=Epic AND status='To Do'")`],
            }
          ]
      },
      { ... a couple more sections here with same structure }
    ],
  },
  
 What I have as options ( keys most importnat ):
 const CheatsheetFuse = new Fuse([sections[0]], {
  includeScore: true,
  includeMatches: true,
  minMatchCharLength: 3,
  keys: [
    'title',
    'subSections.examples.note',
    'subSections.examples.snippet'
  ]
});```


Now searching for something like `isue` ( fuzzy ) returns me correct matches, but with the following refIndex ?

key: "subSections.examples.note"
refIndex: 2
value: "Finds issues that are linked with epics that are in To Do:"

Now this is correct, it's inside the second example, but why the refIndex is not zero-based ?
Also is there a way to understand the position of the match when it is inside nested structures ( in this case - example or even example.snippets[] ) Do I have to go with more normalized data and multiple index instances and fire multiple searches to achieve that ?



### The Fuse.js version where this bug is happening.

6.6.2

### Is this a regression?

- [ ] This is a regression bug

### Which version did this behavior use to work in?

None

### Steps To Reproduce

Search for issue in the example from above

### Expected behavior

I would expect refIndexes for nested arrays to start from 0, currently it looks like they start from 1 ?

### Screenshots

<img width="954" alt="Screenshot 2024-11-15 at 10 59 25" src="https://github.com/user-attachments/assets/cc0d1a09-3bc4-470f-8882-0bce1d743f7d">


### Additional context

_No response_
@Taliss Taliss added the bug label Nov 15, 2024
@uncenter
Copy link

(Looks like you didn't end the code block syntax correctly btw)

@tugkanpilka
Copy link

Did you solve the problem? I'm experiencing the same situation.

@Taliss
Copy link
Author

Taliss commented Jan 14, 2025

@tugkanpilka No, not really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants