Query for pages with property value that contains specific word

I would like to be able to query the pages that contains a particular word in one of its property values. For example, something like {{query (property title "some-word-in-title")}}.

This may be helped by contains?

Here is a sample search I use for TODOs. TODOs are just blocks that start with a capitalised TODO/DOING/NOW/LATER.

#+BEGIN_QUERY
{
	:query [
		:find (pull ?b [*]) 
		:where 
			[?b :block/uuid] 
			[?b :block/marker ?marker] 
			[(contains? #{"TODO" "DOING" "LATER" "NOW"} ?marker)] 
	]
}
#+END_QUERY

A tip I learnt recently for creating advanced queries is by looking at the console output for a page. It will show the advanced query of a simple query. “Ctrl+Shift+i” on desktop. Advanced Query: Blocks excluding certain tag - Questions & Help - Logseq

4 Likes

Thanks! Will explore the usage of contains? based on your suggestions.

I’m a bit desparate at the moment regarding queries.
I’m building kind of a thesaurus for creative and non-fiction writing. In the properties I have category:: wtc (stands for words, terms, concepts - where I collect definitions, links to various pages, thoughts etc. The only way for me up to now to get a list of the pages with “wtc” in the properties is a page named wtc and its linked and unlinked references. Of course I would like the list ordered alphabetically.

A query output-table can sort alphabetically. How could I achieve this via a query? I can’t find a source (and the time too) to get a better grip on datalog (and I guess I’m not the only one) , so I’m asking here.

Thank you so much for answering!!!

Have you tried {{query (property category wtc)}}?

3 Likes

Ah! Yepp that worked! Thank you!

What I miss is the page title in the first column of the table view. But this seems to be a logseq thing somehow.

If it is a page property (that is, property in the first block of the page), you can try {{query (page-property category wtc)}}. That should allow you to see the page title in table view as well.

2 Likes

This is awesome! Now the frustration can go away.
Thank you soo much :heart_eyes: !!!

1 Like