hoelzro / tw-full-text-search

Full text search plugin for TiddlyWiki powered by lunr.js
https://hoelz.ro/files/fts.html
Other
25 stars 4 forks source link

Fuzzy Matching #4

Closed diego898 closed 6 years ago

diego898 commented 6 years ago

Hello again!

I came across this section in the documentation:

https://lunrjs.com/guides/searching.html#fuzzy-matches

and when I tried to change my search string by typing the ~ character I got a series of uncaught errors. If I just press ok and continue until I get the number in like searchString~2 and press Ok a couple more times to some errors, I am actually able to perform the fuzzy matching.

If I just paste in the query with the ~2 attached, I dont get any errors.

Perhaps some error catching could be implemented to ignore this problem as you type character by character?


Also, just wanted to let you know of this discussion google groups where Jeremey mentions trying to incorporate lunr.js! And also this feature request on the tiddlywiki main repository: https://github.com/Jermolene/TiddlyWiki5/issues/3233 where I am also trying to get something like this in the core!

hoelzro commented 6 years ago

@diego898 Thanks for the report - that's a great idea! I'll whip that up when I have a moment.

And thanks for the links to the discussions about goings on in core TW - I'll check that out!

hoelzro commented 6 years ago

@diego898 Thanks again - I've released 1.0.1 and pushed it to https://hoelz.ro/files/fts.html. Please let me know if it works for you!

diego898 commented 6 years ago

Hey @hoelzro! Thanks it looks like its working and I can now fuzzy search!!!

diego898 commented 6 years ago

Just a side note: It might be nice to automatically switch to fuzzy matching if no matches are found. What do you think?

hoelzro commented 6 years ago

@diego898 So add some default fuzz distance to search terms upon no matches, assuming that the user mispelled a word?

diego898 commented 6 years ago

Not necessarily a misspelling, but more than likely yes. In fuzzy matching mispelling can be used a feature. For example, I use

https://github.com/junegunn/fzf

multiple times daily. As an (extreme) example, I can lazily type: dp lrng pdf to find all pdfs with deep learning in their names.

hoelzro commented 6 years ago

Hmm...I'm kind of on the fence on the fuzzy search thing. I like the idea, but it feels like it might be better suited to its own plugin.

diego898 commented 6 years ago

Sorry Rob, what do you mean its own plugin? lunr is the library handling the fuzzy search. With this plugin right now we can do fuzzy search. I was just suggesting adding (perhaps through a configurable option) that when no results are found, the search is automatically run again with a ~1attached for fuzzy searching.

hoelzro commented 6 years ago

I meant having that "fuzzy fallback" live in its own plugin, but I don't know how that would work =/ Maybe I should just add it and try it out as an idea!