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

Highlight matching characters #54

Open
kacpak opened this issue Mar 5, 2020 · 5 comments
Open

Highlight matching characters #54

kacpak opened this issue Mar 5, 2020 · 5 comments

Comments

@kacpak
Copy link

kacpak commented Mar 5, 2020

I think that it would be great if we could highlight characters that triggered the match

search: somestring
result:
foosomestringbar
foosomethingStringbar

API could be something like this

const searcher = new FuzzySearch(people, ['name.firstName', 'state'], {
  caseSensitive: true,
  highlight: substring => colors.underline.bold(substring)
});

What do you think about such feature? I really miss something like this.

@ralf57
Copy link

ralf57 commented Mar 9, 2020

I am not in favour of this proposal simply because it's not the job of this library to handle results rendering.
Instead, it would be great to have more control on the matching algorithm.
For instance, wether is should be stricter or not, etc.
As it is now, the API does not provide anything in this regard.

@kacpak
Copy link
Author

kacpak commented Mar 9, 2020

@ralf57
I think that API strictness should become another issue, since it's not really relevant for highlighting.

I agree that this lib shouldn't handle rendering and this request doesn't change that. It allows for mapping over results with relevant information.
Right now, for my use-case, it's incomplete if I cannot get any information on because of what parts of the string, the object was included in the results.
That's why I'm suggesting a function that allows for mapping over results and modifying them with relevant data.
This function API in description is only proposal to showcase the idea, it could be more generic.

@wouterrutgers
Copy link
Owner

wouterrutgers commented Mar 9, 2020

Something I could do which wouldn't change much in the code I think; would be to return the indexes of the matches somehow. As I already use the indexes to search for matches.

const searcher = new FuzzySearch(people, ['name.firstName', 'state'], {
  caseSensitive: true,
});
const results = searcher.search('something');
const indexes = searcher.indexes();

Something along those lines, probably won't be exactly that. I'll have to figure a nicer way, but that way you can manually map the results.

@SzNagyMisu
Copy link

Hey,
Any news on this one?

@AshwinC8
Copy link

AshwinC8 commented Aug 8, 2024

Something I could do which wouldn't change much in the code I think; would be to return the indexes of the matches somehow. As I already use the indexes to search for matches.

const searcher = new FuzzySearch(people, ['name.firstName', 'state'], {
  caseSensitive: true,
});
const results = searcher.search('something');
const indexes = searcher.indexes();

Something along those lines, probably won't be exactly that. I'll have to figure a nicer way, but that way you can manually map the results.

Is it underway?
would love to have that.

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

5 participants