Anki-android: Feature request: allow using an Anki deck as a lookup dictionary

Created on 12 Feb 2019  ·  34Comments  ·  Source: ankidroid/Anki-Android

Allow looking up words/symbols (e.g. “猫”) not only in external dictionaries (e.g. Aedict, Eijiro), but in Anki's own decks. This way, I could check which other cards contain the word “猫”, or perhaps find this kanji in a kanji deck.

This could work like this:

  • Add another lookup dictionary, like “Anki deck”
  • Add an option “Anki deck search query”, where you could enter a search query such as %s or deck:kanji kanji:%s
  • Perhaps, add an option “Go straight to card preview if only one card is found”

Additionally, it'd be nice if I could use multiple lookup dictionaries at once, maybe via different gestures.

Most helpful comment

(Core devs correct me if I'm wrong here)
I think this issue suffers from "too-many-things" syndrome (which I believe was hinted at here). A (probably incomplete) list of requests mentioned in this issue and probably warrant separate smaller issues:

  • "Add another lookup dictionary, like “Anki deck”"
  • using the Card Browser system context menu to dynamically insert a search term in a user defined search e.g. deck:kanji kanji:%s
  • an option “Go straight to card preview if only one card is found”
  • "use multiple lookup dictionaries at once, maybe via different gestures."
  • allow switching the currently searched decks without removing the current search query
  • search in the original deck when the currently searched deck is a filtered deck
  • select multiple search queries (maybe from a check box menu similar to the one that pops up when filtering by tag?)

All 34 comments

We already have the feature in latest alpha versions to search in the card browser. It doesn't search any particular deck though. Does this feature suit your needs?

as far as i am concerned, if i can search a field (kanji:%s), that'd be enough for me. i looked around in 2.9alpha63 and I didn't see this feature though

If you long click on a word in a webpage, you should be able to find an option "card browser"

this works! but you won't ever find it if you don't know it's there, at least not on p. regardless of what comes out of this issue, this thing must be in on-screen release notes

anyways, the ability to do a search with a configurable query would be much appreciated (and hopefully easy to implement. also, multiple queries seem to be possible via that menu?)

This has several easy to fix problems:

  • Filtered decks search on filtered decks instead of the original deck
  • It searches in the current deck by default
  • When browsing, to change deck, you have to delete the word searched
  • And even if you do it, it is reset with each new search
  • You cant select ask it to search all decks
  • You cant select ask it to search the proper deck

I do this kind of searches all the time and is a very tedious process right now

@voidplayer I don't use this feature personally so I don't have the motivation to hack on it but if you've got time to work through any of those items we happily accept PRs and work with people to merge them

I took a look and honestly i have no idea where to start :)

I grepped "Card Browser" which is too generic and "Search Privately" which yield no results. Those two are the options in the menu i was going to use to search what is the menu button doing. Is the menu even in this same repository?

It is an internationalized application, so the text strings you are looking for are defined in xml string files and interpolated into the user interface. When I try to find code related a string I start by finding the XML lookup key name for the string by looking in those strings files for the interface language I use, then I grep for that lookup key, and the code is resolved that way

I cant find them!

Im using regular english, i tried with several combinations of the words "Copy, Share, Select all ... Search privately, card browser"

I cant find them. Maybe the menus are not written in the strings directly?

Sorry, I dont know much about this. I just assume changing the default deck to search is a parameter in some function somewhere and that is easy to change :)

https://github.com/ankidroid/Anki-Android/blob/master/AnkiDroid/src/main/res/values/07-cardbrowser.xml

and for marked, for instance: https://github.com/ankidroid/Anki-Android/blob/master/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.java#L822

maybe you should grep case-insensitive with '-i' flag for grep?

I can point the way a bit but as a volunteer with limited time I can't direct too much for features that aren't personally interesting or directly related to stability and releases, sorry. With infinite time I could do more but in reality volunteers here have to be pretty self-service and able to slash through problems themselves mostly

Thanks for the help!!

I noticed that the menu is global is not an anki menu. It works outside anki. Its not as simple change for me as i thought :(

I know how to grep, but i believe no amount of grepping is going to help me find the places this have to be changed :(

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

I think in latest version theres been a new feature added to search all decks when no results are found

I would rather being able to change searched deck without having to erase the search term, or having filtered decks search in the original deck, but I think this is a good compromise because is easy to implement and like 80% effective

Can we still have a 'search all' shortcut even if it finds something in the current deck?

@voidplayer, Is that only if coming through the global "Card Browser" shortcut, or for any searches?

Regardless, could you stick in a new issue and I'll see if I can get the change in before we cut out the features for the 2.11 beta.

Both to be honest

The problem with the global 'card browser' shortcut when used within anki, is that is looking one word from a card in the current deck. Its going to always find the card you are looking at and never going to trigger the "0 results. search all?"

What part of this feature request do you want in the new issue?

And thanks for your work by the way! Ive seen you are very active in the project! :D

@voidplayer No worries!

Just pick your comment and "Reference in New Issue" from the menu (and edit slightly to make sure it's understandable without context from this issue). Don't worry about the auto-generated template for this one, that helps us, and I won't need any additional info to fix this.

It's always good to have a "closable" issue (it feels good, it's good for searching, and it brings the discussion into one place). It's much hard to pick up an issue that has many parts to it

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

To be honest search all fixed 80% of use cases for me

@voidplayer What's missing? I'd love to improve things further if the ideas are feasible.

i'm still missing the thing i initially wanted. i want to be able to select “猫”, go to something like Card Browser (btw why is “Browser” capitalized) and have a search “kanji:猫” (which shows the single card for 猫 from my kanji deck, with readings etc)

Yeah, search a field AND a deck

I have a lot of decks, very non related. Depending on what you look for, Seach all can yield many unwanted results. I dont know whats best here. Maybe being able to define a default deck for searching?

And related, it is the problem that you cant switch decks without deleting the word you are looking for. It saves space on screen... but its annoying because, as i said in my first comment on this issue, there are many kind of searchs that look into the wrong deck

For example, if you search while on a filtered deck it searches in the filtered instead of the original by default

Example use case where this is not desirable: learning languages. Original deck have all words. Filtered decks have only a few filtered. Search all fixes this somewhat

And to top this, i have languages i have studied in the past, but i cant "deactivate" the decks without deleting them. I dont think anki wants me to ever stop any deck. If i had to pick a fix, i would pick this one for sure :)

maybe i'm missing something, but why not simply replicate what desktop anki is doing and put something like deck:current into search instead of hiding it in the menus? and have Search all remove this filter? or even use something like chips with a delete button so that you can simply tap that to remove the filter?

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

still searching for solutions

i guess this being closed is an error but i cant reopen it myself :)

It's not really an error - we rely on volunteer contributions and to have issues just sitting around forever as if they are a todo list with no one doing them is impractical. This has existed for more than a year and a half with no one implementing :shrug: I'd have left it closed. Post a PR and we can merge it :-)

I dont disagree, but in that case please fix the message of the bot closing it because it really sounds hostile to somebody that took his time to open the bug report and just followed instructions

Thanks for your work!

i even made the text italic!

I'm late to this issue,, but don't the Save search and My searches items of the card browser cover this? Users can already save a query of "deck:kanji" "kanji:" and then paste “猫” after the kanji: string to search for that. Just searching “猫” should find all cards that contain “猫” in the current deck (or all decks if that chosen)

For switching decks after a query is made, can't you copy the query before switching decks in the browser and then paste it?

This entire bug is all about convenience of use

I have saved a few complex searches that i use, but if the search is not complex enough, it saves time to type it manually because menus are hidden

Also, this does not work with browse card, which is an android-wide shortcut to search text in anki

Right now is so complex that is not really a shortcut, you might as well copy the text, close your app, open anki, change the deck to where you want to search and paste your term.

After a certain threshold, you might as well, google the term instead because is faster if you do it

Also, some times is not just about looking up, but also about finding a car to be able to edit it, either to bump it, to add something, to change its deck, to compare it,...

I do 80% of all those things in the desktop, because the flow in the phone is so so

As i said before, 'search all' is a speedy compromise even if its not ideal or useful for all cases and im mostly fine with it because i understand somebody using those workflows would have to redesign it and code it. And such person have not show up yet...

(Core devs correct me if I'm wrong here)
I think this issue suffers from "too-many-things" syndrome (which I believe was hinted at here). A (probably incomplete) list of requests mentioned in this issue and probably warrant separate smaller issues:

  • "Add another lookup dictionary, like “Anki deck”"
  • using the Card Browser system context menu to dynamically insert a search term in a user defined search e.g. deck:kanji kanji:%s
  • an option “Go straight to card preview if only one card is found”
  • "use multiple lookup dictionaries at once, maybe via different gestures."
  • allow switching the currently searched decks without removing the current search query
  • search in the original deck when the currently searched deck is a filtered deck
  • select multiple search queries (maybe from a check box menu similar to the one that pops up when filtering by tag?)

the first two bullet points is the same thing and will solve the issue. you could say that there is already a "lookup dictionary" that searches for %s, adding another one without changing the %s pattern makes no sense as well as adding a new pattern without means to search it

i'm not sure if you could separate the third bullet point it, where else would you use this kind of setting?

i'm not quite sure about the rest. there's this "search all decks" thing but if i input deck:kanji kanji:猫 in the search Anki does search the kanji deck even though it's not the current deck. (for some reason it still offers to search other decks. another bug?) so, the required machinery seems to be already there, and this just needs a new option

by the way, the "card browser" and "anki card" menus doesn't appear in ankidroid unless i enable them globally, i don't suppose this is right?

so since the functionality is mostly there, i went on and implemented the menu (all options hardcoded): https://github.com/oakkitten/Anki-Android/compare/master...secondary-context-menu-for-card-browser

i don't suppose it's possible to dynamically change activity names (does it have to be an activity?), so i simply added another alias for .CardBrowser to the manifest with the name "Custom card search". I suggest renaming "Card Browser" to "Card search" to express more precisely the intent and to be in line with the other menu items. Also "Card search" and "Custom card search" work nicely together while i'm not sure about the cousin to "Card Browser"... "Card Browser 2"? (also it has weird capitalization)

i also made the card browser finish instantly when the search is closed

i also changed the closing animation to default for the sake of consistency. if what i said in a previous comment is a bug this might need to change

i didn't go for implementing "Go straight to card preview if only one card is found" as doing it on top of this would mean super janky UI, and implementing it without CardBrowser is hard as i'm not familiar with codebase

if this is good i can try making something PR-able

p.s. i'm assuming that intent.setAction(Intent.ACTION_DEFAULT); is called to prevent the block from running again?

Was this page helpful?
0 / 5 - 0 ratings