rode / grafeas-elasticsearch

An implementation of the Grafeas storage backend based on Elasticsearch
Apache License 2.0
12 stars 5 forks source link

Filter question #42

Closed cyberbliss closed 3 years ago

cyberbliss commented 3 years ago

I've started evaluating this storage backend for Grafeas and it looks very interesting, so thanks for making it available :-) I have a question about the list filters that are supported.... I can see that something like kind=="BUILD"works as expected but what if I want to query a nested element such as resource.uri? I tried resource.name=="myimage" but that generated a parsing error. Am I right in thinking this isn't supported yet?

mrparkers commented 3 years ago

Hey @cyberbliss - thanks so much for checking this out! We'd love to hear your feedback if this backend ends up working for you :smile:

With regards to filtering, the syntax error here is most likely due to cel expecting resource.name to be surrounded in quotes, like this:

"resource.name"=="myimage"

When you start to nest elements using the dot notation, it's going to want that particular expression to be surrounded in quotes so it can tell the difference between that syntax and function calls.

If you'd like, you can take a look at some of our acceptance tests for the filtering logic for some examples of how these queries can look: https://github.com/rode/grafeas-elasticsearch/blob/727fde0961f7fd898e67fab40d6b3f0c3e500d67/test/v1beta1/occurrence_test.go#L168-L265

We've even added the .startsWith function recently, so that may be useful to you as well.

Let me know if that works for you, or if you have any other questions. Thanks!

cyberbliss commented 3 years ago

Doh! I didn't see those tests. All works now. Thanks for the quick reply

mrparkers commented 3 years ago

Happy to help! Feel free to open another issue if you have any additional questions.