obsidian-query-language icon indicating copy to clipboard operation
obsidian-query-language copied to clipboard

[Question] Is there any way to exclude subfolders from search?

Open meskill opened this issue 4 years ago • 3 comments

For example

name: "Frameworks"
query:
	path: "^Dev/Languages/JavaScript/Frameworks/"
template: "table"
fields: ["title", "tags"]
sort: "-title"

will return every file at folder and its subfolders which I don't want to see

meskill avatar May 03 '21 15:05 meskill

Does something like below work:

```oql
name: "Frameworks"
query: {
	$and: [
		{
			path: "^Dev/Languages/JavaScript/Frameworks/"
		},
		{
			path: "!Dev/Languages/JavaScript/Frameworks/folder-to-be-excluded"
		}
	]
}
template: "table"
fields: ["title", "tags"]
sort: "-title"
```

If you want to exclude all subfolders, I'm not sure if there's a easy way to do that. You can combine the extended search with the logical query operators..

I'll have a look if it's possible to supply just to path to the note (instead of it's full path). That would allow for just getting the notes in a folder (and not a subfolder)

jplattel avatar May 03 '21 22:05 jplattel

@jplattel Thanks for the suggestion, it works indeed.

But I need to specify every subfolder this way. As I understand there is currently no way to use regexp or smth similar in the plugin?

meskill avatar May 04 '21 08:05 meskill

Yes, right now that's the only way I can think of. I'll include a basePath to query with in the next update of the plugin, that way it's possible in the future! I'll mention it here once it's ready!

jplattel avatar May 04 '21 08:05 jplattel