Find all instances of a particular property

I want to have a list key values for 1 particular property. The amateurish way of doing this would be to write for example type:: and then a dropdown list with all the existing key values for that property is presented.

Is there a query to get the results is a table? I tried this {{query (property type *)}}, thinking that perhaps the * indicates all instances, but it does not, Logseq probably interprets it as having to find a property called *.

1 Like

Yes exactly. And without the * you get all blocks with that property.

So we come back to the advanced query.
Here’s a topic on the exact same question I feel.

1 Like

Thank you, that works.

The query finds the lines that have the property specified in the syntax, then lists them as output. In certain lines there will be more than 1 value, or different value combinations.

So, there may be a line with type:: value1, value2 and another line with type:: value1, value3, value7. Or there is type:: value1, value2, [[value6]] - the double brackets are added automatically because of the Automatic Linker plug-in, I think.

The output of the query is:

value1, value2
value1, value3, value7
value1, value2, [[value6]]

So there are duplicates.
Is there a way to list each value once on a separate line? I don’t mind about the square brackets.

What you see now is a list of actual values. Where value1, value2 is the value in this case. Instead of the property having 2 values. Namely value1 and value2.
It would be 2 values if the config option to consider comma separation as separate pages is on for this property.
It would then be stored as a set. #{"value1" "value2"}
In theory those can then be separated out. Unfortunately this is not something I know how to do.

1 Like

In config.edn I have made the amendment to :property/separated-by-commas #{:topic}, since it is the property topic I am exploring this with. But I don’t see those sets you mention.

In any case, it does not matter because you don’t know how to do the separation afterwards. It is not a big deal because the list as it is now already provides me with what I need in essence.

So, many thanks for your help and patience.

1 Like

It’s because we get :block/properties-text-values and not :block/properties.
And we then do some fancy :view things.
Remove that and you should see it.
Pro-tip: if you turn on developer mode you can right click a block and select show block data. This shows what is stored in Logseq’s internal database and so what can be retrieved using queries.

Yep:

image

But all the values occur between 1 set of quotation marks, rather than each value wrapped within its own set.

You should also change the properties thing I mentioned. Then it will look like this:

If we leave out the :keys we get just the value list btw.

Yep, got it as per your last screenshot:
image

So, what does this mean, what do I do with this?

And another question: I have an empty line, why?
image

Learn Clojure? :joy:
I’ve been wanting something similar and I haven’t figured out how to tell the program to do what I want.
I just wanted to show that it is stored as separate values so it should be possible to extract them.
I’m just not that savvy in programming.

Empty line might be empty value? Maybe in a template or other place where this property doesn’t have anything filled in. (property:: )

1 Like

OK, it’s all clear. I am very happy you helped me with this issue. Like I said, I have the essential part, and that is what counts.

1 Like