Skip to content
This repository has been archived by the owner on May 8, 2022. It is now read-only.

Treat words in query as individual queries for more exact results #6

Open
LinusGeffarth opened this issue Mar 20, 2018 · 8 comments
Open

Comments

@LinusGeffarth
Copy link

LinusGeffarth commented Mar 20, 2018

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 LinusGeffarth changed the title Search for results that conform to multiple words in the query Treat words in query as individual queries for more exact results Mar 20, 2018
@krisk
Copy link
Owner

krisk commented Mar 21, 2018

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.

@LinusGeffarth
Copy link
Author

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

@yushuyi
Copy link

yushuyi commented Mar 29, 2018

looking forward to this

SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 5, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 5, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 5, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 5, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 5, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 5, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 6, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 6, 2019
SchmidtyApps added a commit to SchmidtyApps/fuse-swift that referenced this issue May 6, 2019
@SchmidtyApps
Copy link
Contributor

@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.

@mthole-old
Copy link

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

@andrew804
Copy link

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

@livesafemike
Copy link

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

#26

@krisk
Copy link
Owner

krisk commented Mar 15, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants