Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

boyechko
Copy link
Contributor

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)

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`.
@localauthor
Copy link
Owner

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).

@boyechko
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants