Allow for embedded search result format consistent with links

Use case or problem

The embedded search block only allows for a search list to be embedded. This request addresses an alternate format consistent with existing link grammar with an extension for searching. Thus embedded searches would look like, and behave like, other types of note links

Proposed solution

Suggested format:

[[query|searchTerms]]

Thus a keyword (doesn’t have to be “query”) identifies the link as a search, and the search result embeds a list of links representing the search results. Those links would consistently behave like note links.

Also:

![[query|searchTerms]]

Consistent with (!) in a note link, this would embed the results as if the results are one single document.

Current workaround (optional)

Related feature requests (optional)

1 Like

How would searching for wiki-links work? I guess, brackets would be expected to be paired, i.e. one closing for each opening one, to avoid need for escaping. I.e. ![[query|search [[terms]]]]. Correct?
Edit: respecting paired brackets would make search string much cleaner and easier to compose in comparison with ![[query|search \[\[terms\]\]]] and possible to copy from search pane into markdown file without treatment.

The exception would be regular expressions which should be able to match unpaired brackets “]”, “[”, and slash “/” symbols, for example within character list [^]/]. How would termination of regex within search terms be determined?

My mistake, the examples should have been double-brackets. I’ll correct that.
Termination of regex would work the way it works now: /regex/
Therefore forward-slash would be escaped, as it is now. There is no problem with unpaired (or paired) brackets in a regex because it’s in the context (grammar) of a regex, not outside the regex. Outside the regex, they would be escaped (as they would in a regex). So for example if you use backlinks to collect your recipes and ingredients, (notes containing [[recipe]] for example) and you want to embed links for all recipes containing kale, your search might be

[[query|\[\[recipe\]\] \[\[kale\]\]]]

And now you’ve got an auto-updating note that keeps a list of all kale recipes. Since the query is replaced by all matching notes as links, you’ll be able to hover over each one to see them, which I’d find very useful.

We don’t need to use a keyword like “query”. I suppose it could be anything that isn’t likely to be confused with a note name.

1 Like

I think this idea, while a little niche, would be pretty cool. In a vault with consistent tags, or lots of unprocessed, imported files, embedding or linking searches would be great, especially as the vault evolves and changes in a way that would be hard to update with just tags or wikilinks.