fuse-swift icon indicating copy to clipboard operation
fuse-swift copied to clipboard

Treat words in query as individual queries for more exact results

Open LinusGeffarth opened this issue 6 years ago • 8 comments

First off, thanks for this awesome search library! I love it! ❤️

Say, I have an array of strings:

var array: [String] = ["Hello World", "Testing", "123 Hi"]

If I put fuse.search("hello", in: array), Fuse finds the first string, being "Hello World".
Same result when searching for "hello world", "lo wo", or "world".

However, when searching "world hello", Fuse does not find "Hello World", but I feel like it should.

Can we make it so the words in the search query are being treated as individual queries rather than one string?
(I'm sorry if this feature already exists and I missed it!)

LinusGeffarth avatar Mar 20 '18 19:03 LinusGeffarth

Hey @LinusGeffarth. The feature you’re looking for would require tokenization of the search pattern and the searched string. It’s not currently a feature (although it is indeed a feature and thus implemented in the JavaScript equivalent library Fuse.js). I am working on implementing it in this swift version. Stay tuned.

krisk avatar Mar 21 '18 18:03 krisk

Awesome, am so looking forward to this. Keep me posted! Thanks!

LinusGeffarth avatar Mar 21 '18 23:03 LinusGeffarth

looking forward to this

yushuyi avatar Mar 29 '18 03:03 yushuyi

@krisk I went ahead and built out the tokenization will PR #26. In my initial testing it improved single string match scores slightly but the major improvement comes with Fuseable property weights. Before it had some issues matching terms across multiple variable strings but with the individual word searches it now finds situations where the first word is in one string and the second is in another. See testProtocolWeightedSearchTokenized test for an example.

SchmidtyApps avatar May 06 '19 00:05 SchmidtyApps

Bump for this request. Looks like there is a coded and tested PR available!

mthole-old avatar Oct 04 '19 16:10 mthole-old

Would really like to use this. Why hasn't it been merged?

andrew804 avatar Dec 30 '19 10:12 andrew804

Looks like it has been merged to master but there has not been a new cocoa pods release since:

https://github.com/krisk/fuse-swift/pull/26

livesafemike avatar Dec 30 '19 14:12 livesafemike

Oh wow this has slipped. I’ll push a new version.

krisk avatar Mar 15 '20 05:03 krisk