I am trying to search attachements by file extensions by CQL with the server REST API.
Until now I have tried following query type=attachment and title~"*.bpmn" to find all attachments with the .bpmn file extension.
Unfortunately this doesn’t work and only 2 out of 12 files in the test case are found. I really don’t know why this is so.
The file’s extension is excluded from the file’s title. You need to use sitesearch~"file.extension:bpmn"
Refer to this page for a more detailed explanation of searching for attached files by their extension using the Canned Search for Confluence add-in app.
@sunnyape Do you also know how the CQL would need to be in order to find attachements with different file extensions? E.g. all files with these extensions .jpg;.jpeg;.png?
Alright, an OR is sufficient: type=attachment and (title~"Li*") and (sitesearch~"file.extension:jpg" OR sitesearch~"file.extension:jpeg" OR sitesearch~"file.extension:png")
Okay a new problem has arisen . We develop a plugin simultaneously for Confluence Server and Confluence Cloud and the problem ist that the CQL with sitesearch doesn’t work in the cloud.
It looks like all the articles about searching for attachments by their extension / content type using sitesearch are written for Confluence Server / Datacentre. There doesn’t seem to be an equivalent for Confluence Cloud yet
So, I think you have two options:
Install Canned Search for Confluence. It’s free and if its sitesearch~(file.extension:xyz) function works to solve this specific problem for Confluence Cloud, then that’s great.
If not, just search for all the attachments, in batches, then filter the resulting JSON responses to isolate the particular ones that have the extensions at the end of the title field.
Personally, I’d also raise a Confluence Cloud feature request, as it’s a bit silly that the JSON object title contains the file extension, but you can’t find it via the contains operator in a CQL search.
@sunnyape Thank you again for your help and the detailed explanation of the options.
Yeah, we have already implemented the second option. We have some problems that the search doesn’t always return all the results. In order to improve the search i wanted to include the file extension in the CQL. It was also the case that we haven’t made the next requests, which is fixed now.
I think I will leave it by that.
It was up to the OP who raised the question to raise that request. Why not just just search through the Confluence Cloud feature requests yourself to see what’s there.
It was up to the OP who raised the question to raise that request. Why not just just search through the Confluence Cloud feature requests yourself to see what’s there.
Within the atlassian systems it is not easy to find the right system and then the right ticket. I had already looked but did not find a suitable ticket.
It sounds like the feature request hasn’t been created. The proverbial ball is now in your court to raise that request yourself and see what traction it gets.