Memorize icon indicating copy to clipboard operation
Memorize copied to clipboard

Search function returns incorrect output

Open rene-coty opened this issue 1 year ago • 4 comments
trafficstars

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

  1. Open a big flashcard set
  2. Search for anything
  3. 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)

rene-coty avatar May 13 '24 07:05 rene-coty

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?

david-swift avatar May 20 '24 10:05 david-swift

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…

rene-coty avatar May 20 '24 13:05 rene-coty

I think it could look similar to the one used in settings dialogs:

Screenshot from 2024-05-20 15-33-21

But with question - answer instead of label - path.

david-swift avatar May 20 '24 13:05 david-swift

That would be neat indeed!

rene-coty avatar May 20 '24 16:05 rene-coty

I implemented the new search view and a new algorithm based on FuzzyFind in 1efab42.

Screenshot from 2024-06-02 15-18-56

david-swift avatar Jun 02 '24 13:06 david-swift