Help: Can't get query to work

Hi,

I’ve got a template to capture information for items that I want to read. I capture my readings in my journal using a template that contains a variety of block properties. I’m trying to query based on a block property I created called type. I created a separate page for readings. I’m trying to query all readings with type = “report”. Unfortunately, nothing I do appears to work. Here’s an example of a completed version of the template:

Preparing and Linking Administrative Data: Promising Practices and Lessons Learned from the Child Maltreatment Incidence Data Linkages Project
title:: Preparing and Linking Administrative Data: Promising Practices and Lessons Learned from the Child Maltreatment Incidence Data Linkages Project
type:: report**
author**:: Tara Strelevitz and Claire Smither Wulsin
publisher:: Office of Planning, Research, and Evaluation, Administration for Children and Families, U.S. Department of Health and Human Services.
date published::
pages:: 5
ID number::
link:: Preparing and Linking Administrative Data: Promising Practices and Lessons Learned from the Child Maltreatment Incidence Data Linkages Project (mathematica.org)
subject:: DataLinking
date:: [[2022-07-22]]
status:: Unread
tags::

I’ve tried a simple query: {{query (property type report)}}
I’ve also tried an advanced query:
#+BEGIN_QUERY
{
:title [:h2 “Reports to read”]
:query [:find (pull ?b [*])
:where
[?b :block/properties ?p]
[(get ?p :type) ?t]
[(= “report” ?t)]]
}
#+END_QUERY

I’ve tried “report” both with and without quotes. When I run the query, I get 0 results. Could somebody help me with this query? I don’t know what the problem is. I don’t even know if the query is the cause of the problem or if something is wrong with the property.

Thank you!

Jelphd

Hi Jelphd,

The simply query is correct I’m using it in this example and it works for both blocks and pages.

Couple of questions that hopefully help solve the issue,

  • Are all properties showing up in a different color as a properties block?
  • What version of Logseq are you running?
  • Have you tried a quick re-index? Shouldn’t be needed, but with so many properties maybe the index broke somewhere.

Also, have a look at the block with an external editor, I had a lot of issues because a hidden logbook entry was in one of my templates, that you only see outside Logseq

Hi Bas,

It’s great to finally meet you. I’ve watched your videos on YouTube and used your LogSeq queries site to help me create my queries.

Yes, the properties show up in grey, the remaining text is in grey. Those properties that have no data don’t show up.

Logseq version 0.7.8

Re-indexing did not help.

Thank you,

Jonathan

I copied the note into Notepad++. It doesn’t show many of the fields. I don’t know why. Here’s what I get from Notepad++:

Preparing and Linking Administrative Data: Promising Practices and Lessons Learned from the Child Maltreatment Incidence Data Linkages Project
date published::
ID number::

That’s a lot less than the actual block.

I don’t know if this is related, but I’m running into a problem with my template page. I’m trying to create a template and getting a block render error, see below:

Block Render Error:

report issue

Meeting Note Title project: Meeting Type: ### Attendees ### Agenda ### Notes #### Decisions #### Next Steps

Thanks again!

Jonathan

Hi Baz,

I discovered the problem. Not only is Logseq case sensitive, it also includes the formatting characters in the property name. I bold the properties (e.g., type) in the note, but not in the query. When I remove the bold from the note or add the “**” to the query, both the simple and advanced queries works.

It seems obvious with 20-20 hindsight that markdown’s formatting characters would be part of the property name. Unfortunately, I didn’t think about it when I was debugging my query.

Thanks again for your help, and please keep making with your videos! Even when I don’t learn something new about Logseq, seeing your workflow is thought-provoking and helps me improve mine! :+1:

Jonathan

Hey Jonathan,

Happy to hear you found the solution while I was being occupied. :smiley:
I’ll keep making video’s, love doing that thanks for the kind words, enjoy searching for all your tags.

Bas