jplattel / obsidian-query-language

An Obsidian plugin allowing you to query your notes
176 stars 6 forks source link

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

Open meskill opened 3 years ago

meskill commented 3 years ago

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

jplattel commented 3 years ago

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](https://fusejs.io/examples.html#weighted-search) with the [logical query operators](https://fusejs.io/api/query.html).. 

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)
meskill commented 3 years ago

@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?

jplattel commented 3 years ago

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!