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

How to match result tokens in matchData with original query tokens #519

Open
tmisirpash opened this issue Jun 11, 2022 · 0 comments
Open

Comments

@tmisirpash
Copy link

tmisirpash commented Jun 11, 2022

Suppose that I want I do a search like the following:

const searchResults = index.search('finance *man')

With position token metadata and the default stemmer, the matchData might look like:

matchData:
    metadata:
        financ:
            field_1: {position: Array(2)}
            field_2: {position: Array(3)}
        spiderman:
            field_3: {position: Array(5)}

For each of these returned matches, I would like to store the original query term that was responsible for the match. For instance, *man was the query token that resulted in a match with spiderman, but from the matchData alone you cannot get this information. Does anybody have a solution for this that doesn't involve post-processing the matchData with (potentially expensive) substring algorithms or rewriting the lunr.Index.prototype.query function?

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

No branches or pull requests

1 participant