zk icon indicating copy to clipboard operation
zk copied to clipboard

Extend zk--id-list to query IDs as well as titles

Open boyechko opened this issue 2 years ago • 2 comments

This is a very minor change that does not effect performance, but allows focusing on parts of IDs as well as titles. So I can focus on only the notes I made in 2014, for example, by querying for ^2014, or notes I've made in July of any year with ^20..07.

Benchmarks:

=== bm/zk--id-list+search-ids (10 reps) at 2023-07-16 14:57 ===
((zk--id-list))                          =>  3049 results in 1.01 sec (inc. 0.62 sec for 1 GCs)
((zk--id-list/rb))                       =>  3049 results in 1.00 sec (inc. 0.61 sec for 1 GCs)
((zk--id-list "yomi"))                   =>    41 results in 2.45 sec (inc. 1.75 sec for 2 GCs)
((zk--id-list/rb "yomi"))                =>    41 results in 2.46 sec (inc. 1.75 sec for 2 GCs)
((zk--id-list "^2014"))                  =>     0 results in 2.44 sec (inc. 1.74 sec for 2 GCs)
((zk--id-list/rb "^2014"))               =>   281 results in 2.44 sec (inc. 1.74 sec for 2 GCs)
((zk--id-list nil zk-alist))             =>  3049 results in 1.04 sec (inc. 0.65 sec for 1 GCs)
((zk--id-list/rb nil zk-alist))          =>  3049 results in 1.02 sec (inc. 0.63 sec for 1 GCs)
((zk--id-list "yomi" zk-alist))          =>    41 results in 0.04 sec (inc. 0.02 sec for 0 GCs)
((zk--id-list/rb "yomi" zk-alist))       =>    41 results in 0.05 sec (inc. 0.02 sec for 0 GCs)

boyechko avatar Jul 16 '23 22:07 boyechko

First of all, this makes zk-index-focus pretty much useless, since a query for a documents with some number in the title returns all notes whose IDs include that number.

Second, IDs are not meant to be semantically useful. They might as well be arbitrary. So, in keeping with the zk philosophy, such as it is, I'm not keen on including functionality to search by ID number. There are other ways to do that, if you think it will be useful to you (through dired, for example).

localauthor avatar Jul 18 '23 10:07 localauthor

Second, IDs are not meant to be semantically useful. They might as well be arbitrary. So, in keeping with the zk philosophy, such as it is, I'm not keen on including functionality to search by ID number. There are other ways to do that, if you think it will be useful to you (through dired, for example).

I see your point, and in one of my Kästen, the IDs are indeed meaningless (<letter>-<four digits>) and and this would be useless there. However, you do assign semantic meaning to the IDs elsewhere, such as when sorting by time of creation.

First of all, this makes zk-index-focus pretty much useless, since a query for a documents with some number in the title returns all notes whose IDs include that number.

This, however, would certainly cause unforeseen behavior. ^XXX as I did limits the matches to the beginning of the ID or TITLE. Perhaps only those search strings that start with ^ (caret) would be matched against IDs? Do you have many titles starting with numbers?

Alternatively, and less cryptically, searching id:2014 could focus on IDs containing 2014; any other search strings just searches titles. I can't imagine there would be many instances where the string id:2014 appears in the title.

boyechko avatar Jul 21 '23 23:07 boyechko