Skip to content

Deals with multi part filters#20308

Open
Arthur-Milchior wants to merge 1 commit intoankidroid:mainfrom
Arthur-Milchior:search
Open

Deals with multi part filters#20308
Arthur-Milchior wants to merge 1 commit intoankidroid:mainfrom
Arthur-Milchior:search

Conversation

@Arthur-Milchior
Copy link
Member

Anki deck search features allows to enter multiple part of the filter. For example "math catego" allows to find the deck "category" as a subdeck of "math", and exclude "category" in any deck that don't also contains the word "math".

The same search on ankidroid would only return a deck whose name contains "math catego" literally.

Also, a search for "h::cat" won't show the deck math::category as ankidroid search for the string in the name of the deck not considering the parents.

This commit tries to be as close as possible to anki behaviour. However, anki deck selection uses a submenu that is very different from ankidroid filtering process. So this commit tries to keep the logic of ankidroid filtering process by ensuring that if we search for "math::alge" we still shows "math::algebra" without showing "math::algebra::group" in the deck picker.

A last complexity was that, when the user tap "math:", we don't want to remove the deck "math" from the search result (as it'll reappear as soon as the user has tapped "math::a", since "math" is a parent of "math::algebra" and that we show parents of shown decks). So the search feature considers in this case that "math:" can be either a part of a name of a deck, or that "math" can be the suffix of a deck's parent name.

A bunch of unit tests was added to help understand the behavior of the search feature in mulitple cases.

Fixes: #20306

@Arthur-Milchior Arthur-Milchior force-pushed the search branch 2 times, most recently from e502be1 to 48b187a Compare February 8, 2026 13:21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is intended but maybe the copyright header is wrong

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, probably a copy past. Nice catch

Anki deck search features allows to enter multiple part of the
filter. For example "math catego" allows to find the deck "category"
as a subdeck of "math", and exclude "category" in any deck that don't
also contains the word "math".

The same search on ankidroid would only return a deck whose name
contains "math catego" literally.

Also, a search for "h::cat" won't show the deck math::category as
ankidroid search for the string in the name of the deck not
considering the parents.

This commit tries to be as close as possible to anki
behaviour. However, anki deck selection uses a submenu that is very
different from ankidroid filtering process. So this commit tries to
keep the logic of ankidroid filtering process by ensuring that if we
search for "math::alge" we still shows "math::algebra" without showing
"math::algebra::group" in the deck picker.

A last complexity was that, when the user tap "math:", we don't want
to remove the deck "math" from the search result (as it'll reappear as
soon as the user has tapped "math::a", since "math" is a parent of
"math::algebra" and that we show parents of shown decks). So the
search feature considers in this case that "math:" can be either a
part of a name of a deck, or that "math" can be the suffix of a deck's
parent name.

A bunch of unit tests was added to help understand the behavior of the
search feature in mulitple cases.

Some CharSequence were replaced by DeckFilters so that each use of the
filter against a name does not require to trim and lower case the
filter again. This also allows to have all the (honestly absurdly
complex given the implemented behaviour) logic of the code in a class.

Fixes: ankidroid#20306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deck search should use not search the space symbol

2 participants

Comments