Memorize
Memorize copied to clipboard
Search function returns incorrect output
Describe the bug
Searching for a flashcard in a set can give erroneous output, with flashcards that don't contain the requested input at all. This happens especially when the set has a lot of flashcards, and it can make the search function almost useless
To Reproduce
- Open a big flashcard set
- Search for anything
- See output
Expected behavior
The displayed search result(s) should only be directly related to the input, ie. only contain the searched string
Additional context
You can test my problem with this .csv file, that I regularly use (~ 130 flashcards with a lot of text)
The search function is implemented here:
https://github.com/david-swift/Memorize/blob/0e6cba49ddde128c9fa0b9e7894735113d89e6a3/Sources/Model/Extensions/String.swift#L11
It currently checks whether there is each letter in the string in the right order, and hides a flashcard if this is not the case. So if I search for "hello", both "hello" and "hysterical elephants like loud oboes" will be visible while "world" won't.
In order to make this feature more useful, we could:
- Sort the results by a matching score. This would be confusing done the way searching currently works, so it would be better to create a separate search view similar to the ones in settings dialogs. Selecting a search result would close the search view and focus the flashcard in the edit view.
- Hide flashcards with a low score compared to the best results that technically match the search string as well.
I prefer the first option. What do you think, do you have another suggestion?
I think hiding results that might be relevant is indeed a bad idea, so my preference also goes to the first option. I can't really represent myself how this separate view would look like though…
I think it could look similar to the one used in settings dialogs:
But with question - answer instead of label - path.
That would be neat indeed!