Display search results on a card while reviewing this card?

There’s already a query language awailable to anki users in the search box of the browser view. For example I can search

“deck:Kanji all in one::3.Writing Cards” card:production Keyword_RTK:tool tag:bad-keyword

… and the browser will return me a nice list of cards that match this criteria.

It would be cool to do the following:

  1. Be able to perform such search queries from inside the card template, or maybe have a field that is calculated dynamically and has the results of the search inside.
  2. Be able to yank only certain fields from the search results instead of displaying full notes. For example, we can have these search results in a form of array of json objects. This would allow to format them using javascript and create all kinds of views. Such views would consist of pieces of knowledge from different cards.

The approach is similar to the one used in Semantic MediaWiki and opens a wide range of interesting scenarios.

Is there anything similar in the world of anki plugins? If not, do you think it’s feasible to do such thing as a plugin? Which classes should i access to be able to build and execute my query and grab the results?

5 Likes

This is a nice idea!

I think the best way to implement it in an add-on is via a JavaScript API that uses pycmd() to send search queries and gets the results using the webview_did_receive_js_message hook.

4 Likes

Sounds good, will try to dig it and hopefully produce my revolutionary plugin.