diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 4eec7758f..4f45e1145 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -505,6 +505,7 @@ class Collection: added_in: Optional[int] = None, due_in: Optional[int] = None, nids: Optional[List[int]] = None, + field_name: Optional[str] = None, ) -> str: filters = searches or [] @@ -532,6 +533,8 @@ class Collection: append_filter(FilterToSearchIn(due_in=due_in)) if nids: append_filter(FilterToSearchIn(nids=NoteIDs(nids=nids))) + if field_name: + append_filter(FilterToSearchIn(field_name=field_name)) if concat_by_or: sep = ConcatSeparator.OR else: diff --git a/rslib/backend.proto b/rslib/backend.proto index 899d74a0b..e984b1f97 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -802,6 +802,7 @@ message FilterToSearchIn { // will be due in the next x days int32 due_in = 9; NoteIDs nids = 10; + string field_name = 11; } } diff --git a/rslib/src/backend/mod.rs b/rslib/src/backend/mod.rs index 5d5c2e9cf..48d9065dd 100644 --- a/rslib/src/backend/mod.rs +++ b/rslib/src/backend/mod.rs @@ -351,6 +351,11 @@ impl From for Node<'_> { kind: PropertyKind::Due(i), }), Filter::Nids(nids) => Node::Search(SearchNode::NoteIDs(nids.into_id_string().into())), + Filter::FieldName(s) => Node::Search(SearchNode::SingleField { + field: escape_anki_wildcards(&s).into_owned().into(), + text: "*".to_string().into(), + is_re: false, + }), } } }