Improving keyword filtering
Opened this issue · 2 comments
When filtering on keywords, the current behavior seems to be that only images are selected that match all the selected keywords. However, if an image has multiple keywords/tags, the image is only selected if all the tags have been selected, which makes it difficult to find such photos.
My suggestion would be to change the behavior from matching images that have all to having any of the selected keywords/tags.
After trying to figure out what the corresponding code does (in FilterService.applyFilters
), it seems to be a limitation of the current implementation when dealing with meta data that are array-like (isArrayValue
), such as the keywords. The filtering is done "in reverse", i.e. the code goes through all unselected keywords and rejects images that contain them. While this is fine for single value meta data, for arrays this leads to unexpected behavior.
Example
An example: You select keyA
and keyB
, which means deselecting keyC
. You have images A
(with keywords keyA
), AB
(with keywords keyA
, keyB
), AC
(with keywords keyA
, keyC
), and ABC
(with keywords keyA
, keyC
, keyC
).
Expected result
AB
andABC
are selected because they have both,keyA
andkeyB
.AC
andA
are not selected because they don't havekeyB
.
Actual result
AB
andA
are kept in the result because they don't havekeyC
.AC
andABC
are unselected because they do havekeyC
.
The selection for cases, where only some of the keywords or additional keywords are present, are being reversed.
Yeah I agree that indeed seems to be confusing.
If you have the time, I would appreciate if you can send a PR. Otherwise I don't I will get to it any time soon like O(years)