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

query grammar #38

Open
icornelius opened this issue Jan 7, 2023 · 1 comment
Open

query grammar #38

icornelius opened this issue Jan 7, 2023 · 1 comment
Labels

Comments

@icornelius
Copy link
Collaborator

Prior to zettelgeist v.1.1.5, queries with zfind worked as described in the baseball tutorial. The grammar of query strings has changed, such that

zfind --database index.db --query-string 'tags:"National League"' --count

is equivalent to

zfind --database index.db --query-string 'tags:"National" | tags:"League"' --count

Both queries return 29 zettels, whereas there are 15 zettels with the tag "National League". (In all examples here index.db is populated by the zettels in zg-tutorial/zettels/baseball.) zfind seems to be handling the space character as the operator OR.

The expected outcome is achieved in this case by joining the search terms with an underscore:

zfind --database index.db --query-string 'tags:"National_League"' --count

Yet the behavior of zfind is stranger than this initial example suggests, as shown by the results of the following queries:

zfind --database index.db --query-string 'tags:"AL Central"' --count
zfind --database index.db --query-string 'tags:"AL_Central"' --count

These two queries return 9 and 6 zettels, respectively.

The first query (for the string "AL Central") returns the five zettels with the tag "AL Central" plus four zettels in which the word-token "AL" does not appear in the tags. (The four false returns have the tags "NL Central" and "National League".) In this case --query-string 'tags:"AL Central"' is not equivalent to --query-string 'tags:"AL" | tags:"Central"'. Something else is going on. What?

The second query (for "AL_Central") returns the five correct zettels plus los-angeles-angels.yaml. Again, I do not understand why.

@icornelius icornelius added the bug label Jan 7, 2023
@icornelius
Copy link
Collaborator Author

Just to clarify: queries for single words have the expected results and can be joined with logical operators (& | !) as documented. The unexpected behaviors occur only when the query string contains two or more words, delimited by the space-character or underscore (e.g. "National League", "NL_Central").

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

No branches or pull requests

1 participant