Search code examples
apicqlconfluenceconfluence-rest-api

Advanced Search with Confluence CQL Error


Iam looking for a order function in confluence CQL.

I want to order by TYPE (page, comment, etc) How is it possible?

I tried this, but it doenst work: https://myconfluence.site/rest/api/content/search?cql=text~%22apos%22&type=page&expand=body.storage&filter=order+by+asc

Thanks for your help!


Solution

  • It seems you mixed things up a bit :)

    This query works for me and orders by id

    /rest/api/content/search?cql=type=page+and+text~"apos"+order+by+id+asc&expand=body.storage
    

    Lets see the problems one by one:

    • filter=order+by+asc This does not work, as it is part of the cql syntax
    • order+by+asc You have to tell which field should be ordered by (e.g. id or type)
    • text~%22apos%22&type=page Do not separate with "&", as it is interpreted as 2 query params and not as single cql command. You have to write the key-word "and" to combine several terms.

    I hope this solves your issue. Ordering by type would not have any affect in your example as you only search for pages.

    Find further information here: