Field named "note" is unsearchable because `note:` searches for note type

Just realized why I wasn’t able to search for stuff in a note field that was named “note”… Took me a while to realize this so it made me wish Anki had notified me of this gotcha.

Perhaps in the note field editor there could be a warning when a field is named “note”, “card”, “nid”, “cid” etc. - any special name used in the card browser search.

2 Likes

Just for fun I made a patch that allows you to explicitly search for fields like this: field:note:foo instead of note:foo.

It also automatically changes any normal_field:foo into field:normal_field:foo.

It’s probably better to just do as you said and add a warning when you try to use a “special” name though.

Does this move the bug to fields named “field” now :smile:

Yeah, I imagine the only likely naming collision is actually just “note”.

Well you can search field:field:foo, so it’s not quite as bad as note:foo being entirely unsearchable. It could however be confusing and break existing searches.

It doesn’t feel worth making breaking changes to the search syntax for such an edge case. I just did it for fun.

As a workaround, you can add an asterisk to the field name in your search query. This tells Anki to treat it as a field name, though it will result in a partial match. For example:

card*:foo, cid*:something

https://docs.ankiweb.net/searching.html#limiting-to-a-field

3 Likes

I just renamed the field to “notes”. I have an addon that uses browser search internally and would break if I happened to use for this field, the partial search could have unexpected results. But good to know there was a trick to workaround this.

1 Like