Can we restrict Simple Queries for Blocks to Pages only?

I don’t see how, based on what options I see for Simple Queries but maybe I am missing something and it can be done without having to use Complex Queries.


Click that and change it to pages.

I’ve seen that at some point but I wanted to somehow restrict results to blocks from pages only without going the Complex Query route. The suggestion is for searching for pages, not for “only blocks from pages” (right?)…

That’s a different specification from what the title suggests.
What are you trying to achieve?

I updated the title, don’t know if it’s better. I basically want to restrict simple searches searches to pages only, not journals. I know it can be done with complex searches.

Ah I see. No simple queries don’t seem to support this unfortunately.

For anybody else who might be interested there is a way -also documented in numerous other places in this forum, it just doesn’t apply to my case: if your pages that you want to perform the search against have a certain page-property you can just add:

(AND (page-property type Project) [[TAG]] ...

For my case I would have liked something like (AND isPage ...


You can also do the opposite i.e. set a daily template that adds a property to each journal page and then use (not (page-property ...).

Ok, I am one step closer to my own goal for this topic.

I have created a page property that gives the name of the current page and I can bulk-add it to all *md files in logseq using VSCodium:

page-name:: {{current-page}}

, where current-page is a Macro in config.edn which uses a dynamic variable to get the current page name:

 :macros {
 :current-page "<%current page%>"

Now I can use AND (page-property page-name ProjectX) but what I really want is exclude Journal-Pages from the Simple Query and would like to use a Negation with a partial search, for example NOT (page-property page-name LIKE "2023")

I expect there is no way to have such search functionality in simple searches but thought I’d ask anyway…

Hmm, this doesn’t seem to be working. I thought that <%current page%> refers to the “current filename” which is not the case. If I open the query from the sidebar i get the name of the page in the center pane / working area.

So my previous attempt is nullified by this false premise…

Maybe what you need is a shell script that edit all .md files to include their name as a property.

Yes Alex, that would be a third best choice (after Simple Queries and Complex Queries) but, being fosed on Simple Queries atm, I was researching if anything else logseq-native could be used, like namespaces maybe. Next choice is Complex Queries, where the Page Name is accessible from what I can remember but that would mean starting to grasp Complex Queries :see_no_evil:.

1 Like