Search for Pattern in file.outlinks

I´m new to Obsidian and try to get my Index and MOCs running. What I`d like to achieve is the following:
My MOC looks like:

  1. maintopic1
    1.1 subtopic1

    I put links to all subtopics into my notes (not in YAML header) and created one MOC-file for each maintopic and subtopic where I query all notes with a simple dataview-query (LIST from [[1.1 subtopic1]] and #Tag) This works fine.
    Now I´d like to create a query for the maintopic including all notes from all subtopics. I thought about querying all outlinks starting with “1.” and tried:
    “LIST where regexmatch(”^1", file.outlinks)"
    “LIST where contains(file.outlinks,“1.”)”
    “LIST where regexmatch(^1”,string(file.outlinks))"
    but nothing gives me a result. In the showcase-category I found some comments about this being not possible at the moment because the links are not read as string, but want to get sure that I don´t miss a part or on a completely wrong way.
    Does anyone have a sugguestion?

Best Regards Oli

There is a nesting capability with tags so that might work.

#MainTopic/SubTopic and then just use dataview on the MainTopic to get the list.

Without using Tags, it doesn’t seem possible because DataView can only detect first degree connections and not second degree


MainTopic ← SubTopic ← Note

LIST from [SubTopic] would return all notes but LIST from [MainTopic] would only return the SubTopic and not all notes

Hi aj_86,
thanks for your response. I´d like to avoid tags because they´re not clickable. Perhaps I didn´t use the right words for my expression.
I try to resolve my issue with searching for only the first letter/number of the title of the SubTopic which should be equal to the first letter/numer of the MainTopic.
List from [[1.1 Subtopic]] works for the MOC of the SubTopic but shouln´t the search for all SubTopics beginning with “1” work for the MOC of the MainTopic?

Hi outlawpete,

I think the search doesn’t work because the outlinks are a list and not a string. The Contains function when used on a list requires an exact match.

Try this:
LIST FROM “” where contains(, “1.1 subtopic1”) or contains(, “1.2 subtopic2”)

The above will work but it is not flexible since it requires exact match. is used to convert from the link data type.

I think the simplest solution is to use Tags like:

LIST FROM #MainTopic1
LIST FROM #MainTopic1/SubTopic1

I also personally don’t like to use tags that much since it is not clickable but it seems to be the best fit.

There might be a way to convert the list to string which I haven’t found so maybe try asking the Discord as well or maybe someone more knowledgeable of DataView will also give their input here

Cool, this works :grinning: It´s static but as long as there are not so much subtopics it´s OK for me. I will try the tag-solution as well, because of the flexibility but for now it´s all I need. Thanks a lot
Best Regards

1 Like

Why do you post this under “Share & showcase”? You should transfer this to the “Help” section.