[Feature Request] Support custom search node in Filtered Deck

Recently, I’m implementing the feature to search custom data in the card browser. Via the hook of browser_did_search, it is easy to filter the ids with custom search node.

def _on_browser_did_search_handle_custom_search_parameters(ctx: SearchContext):
    global custom_search_nodes

    if not custom_search_nodes:
        return

    try:
        original_ids = ctx.ids
        for node in custom_search_nodes:
            ctx.ids = node.filter_ids(ctx.ids)
        ctx.ids = [id for id in original_ids if id in ctx.ids]
    except ValueError as e:
        showWarning(f"FSRS search error: {e}")
        return
    finally:
        custom_search_nodes = []

It works well in the card browser:

But I found that it doesn’t work in the searching of filtered deck:

It is helpful to filter cards whose retention is lower than a specific threshold. I want to support this feature in the filtered deck. According to my knowledge, there is no way to hook the search of filtered deck because it is running in the Rust backend:

@dae, what do you think of it?

1 Like

To achieve good performance and make it work across platforms, it is probably best done by extending the existing prop: syntax. The existing property searches reference sql columns, so we’d also need to introduce a custom SQL function like custom_data_f64(key: string).

1 Like

You are right. Extending prop: syntax is consistent with the Card properties. The custom data is also a card property.

Here is my current implement for searching retention:

I hope it could be helpful to you.

I’d forgotten SQLite has JSON accessors these days. I’ve logged this on Provide the ability to filter on custom_data properties · Issue #2491 · ankitects/anki · GitHub so it doesn’t get forgotten about.

1 Like