Logseq Advanced Query Builder

v0.5 Javascript Version Download a test graph

Logseq Query Builder

An Experimental online tool to help Logseq Users build advanced queries from simple commands.
FAQ
How to use
The simple commands are entered as a text outline in the Command Input area
- commandname
    - argument
    - argument
Optionally arguments can begin with any of the words and,or,and,

  • Enter commands in the yellow area below or choose an example.
  • Tick Include Query Comments to show query line comments
  • Tick Copy as code block to wrap query in a Logseq code block
  • Click the Generate Advanced Query button
  • to build the query.
    • Optionally you can include comments for each query line.
  • Copy the generated advanced query to the clipboard>
    • (if necessary scroll down to see the result)
    • Paste into Logseq using Cmd(or Ctrl) Shift V

Why did I build this tool
The reason I created this query builder was for the following reasons
  • Advanced Queries have a complicated syntax that causes errors eg. missing brackets
  • For non developers they can build advanced queries and avoid having to learn programming in clojure and datalog
  • Logseq users can learn by using the examples to generate queries with detailed comments
  • As the generator is web based it can be accessed from desktop or mobile devices as generated queries are always copied to the clipboard
Simple Command List
Queries filter in two ways - pages or blocks

pages command retrieves the special blocks that have ONLY the page information
such as name, page tags, page properties
- these page blocks are placed into the ?block variable

blocks command retrieves every single block in the graph including the special page blocks
- these page blocks are placed into the ?block variable and the page this block belongs to is placed in the ?page variable

You must choose a pages command OR a blocks command (you cannot use noth together)
Note. Wildcards can be full name or partial name using *
test* - starts with text 'test'
*end - ends with text 'end'
*tax* - contains text 'tax'
blocksselect logseq blocks by wildcards
blockpropertiesselect blocks by property values
blocktagsselect blocks by tag
deadlineselect pages or blocks that have a deadline
deadlinebetweenselect pages or blocks that have a deadline in a date range
journalsbetweenonly select journal pages in a date range
journalonlyonly select journal pages
namespaceselect pages or blocks within a namespace
pagesselect pages by wildcards
pagepropertiesselect pages by page properties
pagetagsselect pages by tag
pagelinksselect blocks that have links to pages
- note. Journal page link is your chosen format in your settings. For example Dec 25th, 2022
tasksselect tasks
scheduledselect pages or blocks that are scheduled
scheduledbetweenselect pages or blocks that are scheduled in a date range
About
This web site is hosted on github pages
source code is available here
Release History
v0.1
  • Original release
v0.2
  • clarify pages retrieval vs blocks retrieval in FAQ, Simple Commands
  • Added 'and' and 'or' keywords in arguments for a command, For example
    can now say
    - tagA
    - or tagA
    and also
    - property category, "fiction"
    - and property category, "western"
  • Added a logseq test graph for download to help user test advanced queries
  • Force user to choose either pages or block retrieval, Default to block retrieval
  • improved error messaging
  • improved descriptions for the generated advanced query lines
  • bug fixes
v0.3
  • Added pagelinks command to select blocks with specific pagelinks
v0.4
  • Conversion from pyscript to javascript
Licence
This tool is free to use by anyone. I built it for my own educational purposes to learn advanced queries and I'm still a novice so the generated queries reflect my current understanding of advanced queries that I have been able to test on Logseq 0.8.2 in October 2022
The advanced queries generated are my interpretation of advanced queries from researching the logseq discord forum and links on the logseq site.
I have not yet included the result-transform or view sections of advanced queries as I am still trying to understand them sufficiently to generate meaningful queries.
DISCLAIMER

logseqquerybuilder is distributed under GNU General Public License v3.

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to
redistribute it under certain conditions.

LICENSE

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Please see http://www.gnu.org/licenses/ http://www.gnu.org/licenses/ for details.

WARRANTY

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

LIABILITY

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE
PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

Command Input



            


Generated Query

Include Query Comments Copy as code block



Status