Add UI and scripting support to embedded queries

+1 https://forum.obsidian.md/t/query-blocks-expose-option-to-fold-or-collapse-results/17481/6?u=andavargas

Wouldn’t it be good to have an Operator or Syntax to choose the default sort order for embedded search results?

Proposed solution

As demonstrated in the search sidebar, Obsidian already has the capability of rendering results as sorted by: File name, Modified time, and Created time; each in forward or reverse order.

This would be so valuable to include for frequent search terms for both Embedded results and URI results.

Example

I’m certain no example is necessary but to provoke the imagination and hope, it might look something like this:

'''query
Search Term
sort:modified
order:reverse
'''

and

[SearchTerm](obsidian://search?query=SearchTerm&sort:modified&order:reverse)

Really, every results modifier that’s currently available could be included to condition the default presentation of any particular query, like: Collapse results and Show more context.

13 Likes

+1 absolutely essential to make sense of embedded queries in MOCs.

+1. Please let it also support Obsidian Publish so that I can share feeds of the latest.

1 Like

+1, would be super helpful

This would be very useful for creating automatic MoC and ToCs.

Especially when combined with automatically transclude the results of embedded query and Folding Embedded/Transcluded Notes.

2 Likes

For now I managed to implement something similar with a smal script and the DataView Plugin.

```dataviewjs

dv.taskList(dv
   .pages()
   .file
   .tasks
   .where(task => task.text.includes("#Deadline"))
   .sort(
   		task => task.text.split(" ").filter(x => x.contains("#Deadline"))
		, "asc"
	)
	.map(task => {
		task.subtasks = [];
		return task;
		}
	)
   )

This would print all nested Deadline Tags (#Deadline/2021-10-01, #Deadline/2021-10-06) chronologically.
Feel free to adapt. Please note that only tasks are included. Normal Text lines with #Deadline would not be found. Haven’t found yet a way to improve this.

1 Like

Use case or problem

I have multiple medical issues. I’m trying to log symptoms in Obsidian as they occur. I’ve tried one large log for all issues and creating individual notes when each event occurs. Either way, I’m trying to create a note that queries the rest of the vault based on a tag and creates a note on only those things I select. However, I need the entire block or small note, not the ellipsis followed by the text I’m getting in the embed (…xyz). If I go into the search and hit the “more context” button, I get exactly what I want. But I can’t export that to a PDF to my various specialists.

Proposed solution

Just add a “show-more-context” query operator to the query language and have it run the same code that’s already tied to the button in search.

Current workaround (optional)

Related feature requests (optional)





7 Likes

Not sure if I understand you correctly, but I think that is already possible (or it might be a plugin that I am using without being aware):

hope this helps!

They don’t want to have to do that each time for every result. I believe they just want the button like in native search bar that shows the full context for all results instead of having to click the arrows one by one.

I also really want this as I would like to be able to sort the results by date created or modified with the sort button. Also the collapse / expand all results is a nice feature too.

2 Likes

Exactly. Because I want to be able to easily query just the information each specialist wants and export to a PDF.

I guess what I really want is for them to put the button functionality in the search feature into the inline query system using query operators. Their documentation on the search feature already implies it (whether they meant to or not), and I spent a lot of time trying to use query operators to no avail. (Search - Obsidian Help)[Search - Obsidian Help]

1 Like

+1. This would be super-helpful for MOCs.

Maybe it is a seperate request but limiting the number of results would also be very nice. I have ben using it for a while and some results become very long. Or even instead of limit 10 something like list 10 that would result in an unlimited result list but with only 10 results per ‘page’. With previous and next buttons and the number of pages in the result.

I will have to back you up on this one. I heavily use search queries because I think they have great potential to resurface information. I also try to keep things simple in my vault so I’m not that keen on using Dataview. Adding functionality into embedded queries would for sure make my life easier !

1 Like

I like this attitude. Stay independent, keep clean and flexible, make your own solution (by using multiple already-existing feature sets), if possible, and so you understand better how your system/workflow works because you cobbled it together…

1 Like

Another +1 for this

+1000

I would also love to see this feature.
Specifically, I want to query all my admonition (codeblocks) and display them fully rendered.
Currently I can only show the code version and it’s collapsed
image

A fully rendered admonition quote would like that
image

I guess that same logic would apply to any code block.

Dataview isn’t an option at the moment because it can’t search the body of the note yet.

1 Like

Can a mod please add the tag for “Search” to this request. It took me a while to find this FR again because I was looking under Search tag but it is only marked as “Valuable”. Thanks! cc @WhiteNoise

+1 for this!