New search node “math:
”
I have implemented a search node which makes it possible to filter cards by comparing fields and properties numerically (code on Github).
Syntax
math:[mathematical expression][<|>|=|>=|<=|!=][mathematical expression]
The expressions may contain numbers, the operators [+|-|*|/]
, the property variables [due|ivl|ease|lapses|reps]
or any other string which will be interpreted as a field name.
Examples
-
"math:Freq 1<Freq 2"
... finds notes which have fields “Freq 1” and “Freq 2” and where the value in the former is numerically smaller than the one in the latter. -
math:due<0.05*ivl
... finds cards which have less than 5% of their current interval remaining (useful for studying ahead). -
math:lapses>0.2*reps
... finds cards where lapses account for more than 20% of the reviews.
Todos
The code is fully functional and ready to go. There are a few features left that might be nice to have, though: *-
Escape characters (so field names containing “-”, “!” etc. can be used)* -
Parantheses* -
Real division (currently,*10/3
evaluates to3
) - Maybe filtering out notes with non-numeric content in a specified field (oversimplified, non-numeric strings are interpreted as 0 by SQL)
-
Maybe multiple equation operators (
math:10<reps<20
) *
Feedback
If you have any use cases where this functionality would be advantageous or can think of a feature that would add even more benefit to it, I would love to hear about it.And now the question of questions: Would you accept a pull request once the aforementioned issues are addressed, @dae ?
* edited lines