REST-API Search content by attachment extension or type of media with CQL

I would like to search for PDF attachments via CQL over REST-API. Unfortunately I have not found a way. The options found so far only concern Confluence Server/Data Center but not Confluence Cloud.

title field of attachment seems not contain the extension in index cause the REST-API returns title including the extension but i can’t find the content when i search for type=attachment and title ~ "pdf"

Does anyone have a tip on how to do this or is there an example to make this possible?

Hi @MarkusWeigelt,

I couldn’t find a straightforward option for Cloud either but you could explore the ones suggested in this reply.

Hope this helps,

Thx for your response. Below are my results:

Answer to option 1:

Canned Search for Confluence does not solve the problem in my case and this is cause of following quote:
> It looks like all the articles about searching for attachments by their extension / content type using sitesearch are written for Confluence Server / Datacentre.

Besides it adds standalone macros and does not change the search behavior of Confluence Cloud to search over REST-API. Correct me if I am wrong! :slight_smile:

Answer to option 2:

This will surely work but with a bad workaround. For example, if I want to search for the PDF’s of a space, I don’t want to load all the attachments and then throw away all the ones that don’t fit. This increases among other problems the load on the system and especially the loading times in the browser.

Why is it so difficult to include the media type in the index?