jplattel / obsidian-query-language

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

Clarify how to use Logical Query Operators? #6

Closed NeighNeighNeigh closed 3 years ago

NeighNeighNeigh commented 3 years ago

Hey again,

I am trying to get OQL to list all notes that contain the strings "[[Blender]]" and "#SoftwareTechnique"

I started off using the following syntax: query: "[[Blender]]" $and "#SoftwareFeature"

And then tried:

query:
  $and:
  - "[[Blender]]"
  - "#SoftwareFeature"

But sadly neither of these has worked.


My current code is as follows:

```oql
name: 'List #SoftwareFeatures'
query:
  $and:
  - "[[Blender]]"
  - "#SoftwareFeature"
template: "list"
badge: false
debug: true

With the debug output showing no results:

// Debugging OQL, total results: 0 // Query: [object Object] // Results:



and I can confirm running the following search in Obsidians search pane returns the results I am after: `"[[Blender]]" "#SoftwareFeature"`

Could you please help explain how to get this up and running?
jplattel commented 3 years ago

Hey @NeighNeighNeigh!

Thanks for creating this issue, I'm planning to document more on the query building and seeing where the friction arises is useful for me!

As for the query you described I could make it work with:

```oql
name: "testing"
query:
    $and:
        - content: "'#SoftwareFeature"
        - content: "'[[Blender]]"
template: 'list'
debug: true


_Note the ' before each content search, as this makes an exact match!_

This does result in #5 which includes the current note. The next version should have a switch for that, so I'll tackle that in that issue :)
NeighNeighNeigh commented 3 years ago

Thanks, unfortunately when I use the above code, I only get one result - that being the current note.

image
NeighNeighNeigh commented 3 years ago

Ah okay seems the problem is it will only find a note containing "[[Blender]]" if it's not part of a longer string. For example the following is not found "# Render with multiple machines in [[Blender]]"

I tried removing the ' before [[Blender]] also, but that didn't help.

jplattel commented 3 years ago

Mmh, interesting! I did indeed try it out locally without putting it in an entire string.. I will try to reproduce it! Thanks for the extended feedback so far! :)

jplattel commented 3 years ago

Alright, I've gained some additional information on this issue. I think it has to do with the way the data is cached within Obsidian which I then use to build the index. It seems like such specific query operators are somewhat unstable and depended on a good index...

Will investigate some more and hopefully reach a solution soon :)

jplattel commented 3 years ago

@NeighNeighNeigh in version 2.0.0 I've switched to a different property for indexing the content, if possible could you try again? The queries seems to work for me right now :)