artifactoryartifactory-query-lang

How can I add 'path' to my Artifactory AQL query?


I'm using insomnia to make calls to the Artifactory API.
I have the following query, which works really well:

items.find({"repo":{"$eq":"my-repository-virt"}}, {"$and":[{"@my.fileType":{"$match": "jar"}},{"@my.otherType":{"$match": "type2"}},{"@prodVersion":{"$match": "false"}}]})   

But I have a problem in that there are duplicate files in some sub-folders with the same properties/filename that I would like to exclude.
I would like to add path to this query, but I can never get any results returned.
The repository is a virtual repository that links to 3 other real repositories.

One of my colleagues can call the following query with the command line tool and get the expected results:

 jfrog rt search my-repo-snapshots/myproject/subfolder/jars/*.jar

I have tried adding the path parameter to my query, I've tried removing everything except the repo and the path, like this:

items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : "my-repo-snapshots/myproject/subfolder/jars/*.jar"})

I've tried with just the path, with variations on the path, including/excluding the repo name, using the virtual repo, the actual repo, but I always get a successful search with 0 results returned.

How can I build this query to search the virtual repo, along a certain path, and including certain properties?

EDIT:
I've also tried:

items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : {"$match":"my-repo-snapshots/myproject/subfolder/jars/*.jar"}})   

Both with the repo in the path and without, I still get 0 results.


Solution

  • OK I figured it out.
    The path part needs to be added in with the {"$and": ...} section where the properties are included. Like so:

    items.find({"repo":{"$eq":"my-repository-virt"}}, 
    {"$and":[
    {"path":{"$match":"path/to/relevant/folders/*"}}, 
    {"@my.fileType":{"$match": "jar"}},
    {"@my.otherType":{"$match": "type2"}},
    {"@prodVersion":{"$match": "false"}}
    ]})