Get callback with found words?
See original GitHub issueWhen using
idx.search("search")
I would like to get an return value with an array containing all the words that were found in the entry, like:
[{
"ref": 1,
"score": 0.87533,
"words": ["searching", "search", "searched"]
}]
This would give me the opportunity to e.g. highlight exactly those words which were found. Is there a way?
My problem: When using lunr in combination with something that handles search results, like a highlighting component, inconsistent behavior will happen. For example if you search for “searched” all entries with “search” or “searched” will be found. However, just “searched” will become highlighted (because those components may not contain things that lunr has built in, like stemming). So I need a way to determine exactly those words which were found in the entry by lunr. Rebuilding the algorithm seems quite excessive and unnecessary to me.
Issue Analytics
- State:
- Created 8 years ago
- Comments:20 (9 by maintainers)
Top GitHub Comments
Sorry for the lack of response, I’ve been spending some much needed time away from a computer!
The wrapping idea came from a library a friend create a while ago: https://github.com/benpickles/wapper, it is slightly old now, but should give some ideas for implementing the wrapping of characters in some dom element.
I’m actively working on the changes required to provide the positional information of tokens, the change is part of a larger re-work of the internals of the library. I can’t commit to a date etc, but it is in progress and I hope to share what I have as soon as possible.
@olivernn I am willing to to implement an adapter, but I need your help in order to do this!