So, how do you actually RUN a query?

I don’t mean how do you write a query. I mean, once it is written, what is the key or keys to press that causes the query to execute?

I had assumed it was the Enter key (aka Return). But when I press Enter, all it does is create a line break within the query. I will demonstrate.

When I consult our friend Dario, he demonstrates a query thus:

Screenshot 2024-09-17 082701

And then he hits a key on his keyboard (he doesn’t say which one), and the result is this:

Easy! So I write my own very first query ever:

image

Then I press the Enter key, and the result is this:

image

I am missing something basic. What is it?

Esc is the key that produced your pic #2.

Return works as well, but only when the caret is at the end of the line.

P.S. It takes less time to try out every single key on your keyboard than to write your post. That might sound silly, but trying everything is arguably the most efficient (and fun) way to learn about an application.

1 Like

[Edit: realized after posting that “pic #2” referred to Dario’s pic #2, not my pic #2]

Thanks very much for that! Dario did not explain the necessity of the Esc key – nor does the Logseq queries documentation explain it, either. Or, if it does explain it, I have yet to find the explanation after reading through it.

For the sake of detail: Enter moves focus to the next block. Esc highlights the current block. So it is strictly Esc that produced pic #2.

1 Like

Maybe the following helps:

  • Blocks have two modes
    • editing mode
      • when you see your cursor blinking
    • viewing mode
      • (default mode) displays formatting expressed in editing mode, executes queries, etc.
      • When you click on a block that is in viewing mode
        • you switch to editing mode
          • your cursor appears,
          • and you can start writing.

When you are writing your query {{query #agenda }} you are in editing mode.
When you press Esc, you exit the editing mode and switch to viewing mode.

  • If you are writing your query and press Enter:

    • you start a new block in editing mode (moving over any characters after where the position of your cursor when you pressed Enter).
    • The block from whence you came is now displayed in viewing mode.
  • When in your question you are writing your query and press enter between {{query #agenda and }}:

    • the block switches to viewing mode.
    • The syntax in the top block does not match the needed syntax for a query (it is missing the closing }}.
      • It is just recognized as a word {{query a space _ and a tag #agenda (you may notice that #agenda in your picture is now displayed in blue and is a link).
        image
2 Likes

This was the unknown-unknown to me, yes. Thanks to you and to @meowkman for clarifying so well. This is the kind of information that is 1) so basic that no one ever thinks to put it in the documentation, yet 2) required to put the documentation to use in the first place. Of course, it’s possible this info is in the dox and I’ve simply missed it, in which case an argument can be made that it should be promoted into a more obvious “necessary prerequisites” location.

2 Likes