Search Operators for LINKS (backlinks, forwardlinks)

Would a Regex search that includes links to files within a folder (also with headings and block references) be enough? That also works in the graph view when you use it as your search. (Make sure to include orphans.)

(?:\[\[(?:\.\.\/)?(folder\/.+)(?:#|^|\|)[\^]?.*\]\])|(?:\[\[(?:\.\.\/)?(folder\/.+)\]\])

This supports one level of nesting (at least that’s what I’ve built it for.)
It includes the links from files in the root level or files in one folder to another folder.
Exchange folder with your folder name.

This only works if you use relative links.

Don’t forget that you need to put the Regex between slashes.

You can use this Regex to find all the links to a particular file in a particular folder:

(?:\[\[(?:\.\.\/)?(folder\/(file))(?:#|^|\|)[\^]?.*\]\])|(?:\[\[(?:\.\.\/)?(folder\/(file))\]\])

Here file is the file name.
Let me know if that helps.

1 Like

Is there a Regex that would simply list all outgoing links from a particular file?

The use case I have depends on another feature request:
https://forum.obsidian.md/t/assign-tag-to-multiple-files/9750/8

I’d like to be able to compose a search query that lists all outgoing links from a specific file, then assign a tag to all of those notes.

@dsteinbock Some relevant regular expressions are in:

If I remember correctly, some initial version of the following plugin already did list all links (also in UI) in a file so you might save some effort: GitHub - mrjackphil/obsidian-jump-to-link: Quick jump between links using hotkeys

1 Like

This will get you all the links. It will only match the file name.

(?<=\[\[).*?(?=(?:\]\]|#|\|))

Use case or problem

I would like to be able to search all backlinks for the selected file and combine it with a filter for example by tag or other parameters

Proposed solution

  • add backlink parameter to specify a search backlink

Current workaround (optional)

I don’t know how to achieve it

2 Likes

Alternative would be filtering directly in backlink pane, requested as part of Filtering Everywhere!

But having the option available in search has use cases too.
Desired in:

  • Obsidian url scheme
  • Embedded searches, with ability to reference containing note without breaking the search when the file is renamed and all backlinks updated.
    For example by accessing variable “filename” of current file, e.g. as link:{{filename}} or link:(!filename).

AFAIK, Embedded search is the only place where it makes sense to speak about “backlink:”, otherwise it is going to be just “link:”. E.g. “link:(file name)” as a convenience to match all links to corresponding file:

[[file name|wiki link]]
[[file name.md|wiki link]]
[markdown link](file name)
[markdown link](file name.md)
[some text](encoded%20file%20name)
<auto link file name.md>

Edit: this does not yet specify query for all unlinked mentions for a file identified by filename, i.e. ordinary matches for filename, title and all aliases.

Related feature requests:

2 Likes

But you can also have unlinked mentions and this way it will be complicated to search

1 Like

I was just about to create another feature request Orpan Search Query and realized that this standing request could probably accommodate that use case if it was implemented. (Atomic requests are more manageable, so let me know if this seems like it should be it’s own feature request.)

Orpan Search Query

It would so be useful to see an ordered list of orphan files.

Proposed solution

Clearly Obsidian already has the capability to filter orphans, as demonstrated by the Graph View filter toggle.

I want some way to do the same thing in the search bar and inline queries.

Graph view is nice, but it’s so random and unwieldy in a large vault. We need a search query that provides a sorted list in the search bar and inline

` ` `query
is-orphan:
` ` `

Or in the style of the proposed solution above,

` ` `query
links:NULL
` ` `

Please note that to be an orphan file, it must not have any Obsidian links in the body nor any back-links. There are several posted regex queries on discord. None of them address the back-link side of the connection.

Current workaround

Progress clumsily using the Graph View filter.

Related feature requests

2 Likes

+1 for this.
A link search operator would also enable to search for all links with a special character (i.e mark transient notes not yet created with [[~ a special character to put in the writing inbox]]).

1 Like

I agree with the original proposal and just wanted to give a particular example.

Use Case:

If I’d want to find all Leetcode problems (tagged with: #leetcode/problem), which also have links to [[Stack]]. Similar things can be accomplished with the DataView plugin, but it’s not as dynamic as it would be by simply searching.

In General:

Making a search query which combines tags, links, and text content is something I often need to do.

Using Regex doesn’t seem like a natural way of accomplishing that.

5 Likes

+1 seems very valuable

As a search operator it would allow booleans (find all notes that are linked from one note, but not from another, or linked from multiple notes), filter in the graph view, and create very useful organization as an embedded search query.

What about “incoming:”, “outgoing:” as search operators?

incoming:Foo or outgoing:Bar or outgoing:"Note With Spaces In The Name"

And negative filter -incoming:Foo or -outgoing:Bar

7 Likes

+1.

I think “incoming” and “outgoing” are simple search operators here.

This would make it significantly easier to find files that have multiple links. Lets say I had two MOCs, one for a company I work for (i.e, Disney), and one for projects.

With this functionality, it’d be simple to do outgoing:Disney outgoing:projects to find all files that link to both. Now I have a list of all projects worked on at Disney.

6 Likes

+1

Combining several links and combining links and tags in the obsidian search would be invaluable. Otherwise tags remain a lot more useful for working with notes. Links, however, are great for Graphs and I don’t want to lose that functionality.

Am I right though that the Dataview plugin already includes a links search along with tags, etc.?

1 Like

yes, in dataview you can search/filter by links (inbound and outbound)

2 Likes

+1 for incoming: and outgoing: search operators.

I also want to add a usecase for this. I use the daily note to track meeting notes with multiple people. It looks something like,

## #meet with [[person1]], [[person2]]
...
...

## #meet with [[person2]], [[person3]]
...
...

Having search over an entire file in this case is not super useful, however it’d be great to combine with line:, so something like,

line:(outgoing:person2 outgoing:person3 tag:meet)

would very precisely capture this usecase.

Workaround: I’m currently doing the same with just text search instead of outgoing link search. Kinda works for now but link would be more precise.

1 Like

Most people don’t include folder names in the links so this won’t work. I wish there was a solution :sweat:

I would like to be able to query by links. Both incoming and outgoing if you can.

But specifically I am using some links as tags, for example “[[moscow]]”, therefore I want to find all documents that have “[[moscow]]”. But simply line:“[[moscow]]” does not always work, because sometimes it’s “[[moscow|Москву]]”. There are some arcane regexes mentioned above, but can you maybe please grant us this simple request of letting us query by inlinks and outlinks? Just like we can query by tags.

I’ve quit Evernote because they wouldn’t let me have simple queries. Obsidian is better, but this request is going for years already, this is some fundamental thing, I don’t see how you don’t make it top priority feature.

4 Likes

Just wanted to add a +1 to the incoming: and outgoing: search operator suggestions!

My current use case is for an embed search query on a persons page with all of the meetings in which I’ve referenced their name.

This is what I’d like to be able to do

outgoing:"@Persons Name" tag:#meetings
1 Like

I find it very strange that this can’t be done considering how quintessential of a function links are in Obsidian. Even [[link]] can’t be searched.

Why I would like this:

I’m a heavy user of Canvas. I would like to be able to drag and drop notes with the link [[Ethics]] to a Canvas, which would be easy if I could have them displayed in the search pane.

Dragging notes from the [[Ethics]] backlink pane to the Canvas works, but it’s tedious because every time I’ve dragged a note into the Canvas, the Canvas becomes the active note and the backlink pane clears. It also only allows dragging one note at a time, because you can’t select multiple notes and then drag them.

In this case, being able to search for [[Ethics]] or link:ethics and drag notes from the search results would be a lot easier. Although you can’t select and drag multiple notes there either, the results would at least remain visible even when the Canvas file is active, which isn’t the case for the [[Ethics]] backlink pane.

(This pairs nicely with another suggestion: Select multiple notes in the Search tab )