question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get callback with found words?

See original GitHub issue

When 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:closed
  • Created 8 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
olivernncommented, Apr 11, 2016

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.

2reactions
julmotcommented, Apr 5, 2016

@olivernn I am willing to to implement an adapter, but I need your help in order to do this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Words unscrambled from letters callback - All Scrabble Words
4 letter words made by unscrambling the letters in callback · alba · baal · back · balk · ball · caca ·...
Read more >
How do I get an event callback when a Tkinter Entry widget is ...
Bind your callback to the StringVar using the trace method. from Tkinter import * def callback(sv): print sv.get() root = ...
Read more >
Callback - Scrabble Word Finder
35 Playable Words can be made from "CALLBACK". 2-Letter Words (6 found). aa · ab · al · ba · ka · la....
Read more >
More Search Element Callback Examples - Google Developers
This page holds an assortment of examples of using Search Element callbacks. They supplement the examples found in Callbacks section of the Custom...
Read more >
Share Data Among Callbacks - MATLAB & Simulink
For example, you can find the current position of a slider by querying its Value property. ... Example: Word Cloud App Using Callback...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found