Make Browser Search Find De-Clozed Text

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I have an issue when […]

I have a collection of Cloze cards for learning the spelling of words. An example for “mnemonic” in the

(A) {{c1::mn}}{{c2::e}}monic (is a trick for remembering something.)

My problem is that searching for the “mnemonic” card in the card browser is tricky due to the cloze deletions in the middle of the word. Simply searching for “mnemonic” does not find the card.


As a workaround, I have tried adding the un-clozed name into a hidden field, but this is a hassle to do, and I don’t do it consistently. As I result, I often can’t tell if I already have a card for a given word and end up creating duplicates.

I expect that the need to use an un-clozed search text to search through cloze cards is not uncommon. In fact, I would always rather have search results based on the un-clozed versions of the cards.

My suggestion is one of the following:

  1. For the purposes of searching, remove all of the cloze tags from cloze cards. Thus, (A) {{c1::mn}}{{c2::e}}monic (is a trick for remembering something.) would treated as (A) mnemonic (is a trick for remembering something.).
  2. Combine Item 1. with the existing behavior, so a search would match against both the clozed and unclozed text.
10 Likes

Your suggestion is a great idea. For the timebeing, you could use some HTML trickery to get around this by adding the word which is in cloze like so (it’s only a workaround until it gets implemented, if it does)

<span style="display: none;">mnemonic</span>

This will allow you to see the cards which have the word mnemonic in it, but will not display this as a part of the content of the card.

2 Likes

Sounds like a useful feature to have for sure, one that can be implemented in the same way as the “ignore accents in search” setting, but it’d require adding a toggle to the settings page for the same reason: it’d make searching slower

@dae thoughts?

5 Likes

I’ve done something similar where I have a field in the card template that is not displayed on the card.

3 Likes

@dae pinging again as requested. imo this would help make searching through clozed sentence decks much easier, especially for CJK languages

2 Likes

I cloze parts of my deck like this and its really useful for science. Some examples:

  1. centri{{c1:petal}}, centri{{c1:fugal}}
  2. {{c1:syn}}carpous, {{c1:apo}}carpous
  3. {{c1:endo}}gamy, {{c1:exo}}gamy
  4. {{c1:di}}cot, {{c1:mono}}cot

And I can mention other words with the same common affix.

I’d recommend you start with a benchmark, as it may be slow compared to the accent search. If so, a similar approach to consider extending sort field to all fields and/or changing HTML stripping · Issue #1085 · ankitects/anki · GitHub may be required.

1 Like

Instead of having it be always-on via a setting, a search option like sc:... (strip cloze) could be added like nc:... for accents

Yep, we definitely wouldn’t want it on by default. But if it’s sufficiently slow, an on-the-fly approach may not be practical at all.

Could we just allow searches to match the Answer field? The text there is already un-clozed, so it achieves our objective.

1 Like

The question and answer require rendering the card, which goes back to my previous reply. There’s a big difference between showing 20-50 questions as you scroll vs rendering potentially hundreds of thousands of cards for a search.

Opened a pr:

4 Likes

I added a section with the sc keyword in the Anki manual under the searching.md :slight_smile:

3 Likes