fuse-swift
fuse-swift copied to clipboard
Treat words in query as individual queries for more exact results
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!)
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.
Awesome, am so looking forward to this. Keep me posted! Thanks!
looking forward to this
@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.
Bump for this request. Looks like there is a coded and tested PR available!
Would really like to use this. Why hasn't it been merged?
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
Oh wow this has slipped. I’ll push a new version.