Tags scoped to search: add tagsForSearch(query) RPC method

Is your feature request related to a problem? Please describe.
In clients like AnkiDroid, the Card Browser populates its tag filter list using allTags(),
which returns every tag in the collection regardless of the active search context. When a user is already filtering by deck, flag, or text, the tag list still shows tags from unrelated notes, making it cluttered and harder to navigate.

Describe the solution you’d like
A new backend RPC method that accepts a search string and returns only the tags present on matching notes:
tagsForSearch(search: String) → List

Describe alternatives you’ve considered
Fetching each matching note individually on the client side and unioning their .tags fields
but this is O(n) note fetches and not viable for large collections.

The AnkiDroid card browser has been AnkiDroid-specific in the past. Should this be posted in the AnkiDroid category instead?

I guess the question is – Are you requesting a change in AnkiDroid? Or is this a change that needs to be made in desktop Anki so that AnkiDroid can inherit it?

Thank you.

The reason I posted this in the main Anki category was that, while the issue originated from an AnkiDroid GitHub issue, the required change does not seem to be limited to the AnkiDroid application itself. During implementation, I found that the functionality would require support from the shared backend/API layer that AnkiDroid depends on, rather than only Android-side UI or frontend changes.

So my understanding is that this may need to be addressed upstream in the backend first, after which AnkiDroid could inherit and use the functionality.

Given that, I was unsure whether the discussion would be more appropriate in the main Anki category or the AnkiDroid category. Could you please let me know where this type of request is best suited to be discussed?

Thank you, that helps clarify things. You were on the right track, but I’m going to move this to the Development category, so you can discuss this idea with devs.

Thank you​:raising_hands:

I always wanted to have the ability to get any note/card property quickly giving a search query in add-ons.

From a quick look at the code, it doesn’t appear to be difficult to extend the search logic to add an option to return tags if someone is interested in contributing a PR.