API search sorting

Liam Jones July 23, 2012

I need to pull a combined list of the 'X' latest pages and comments for a specific space sorted by creation date (for display within another intranet application).

The space and content type restriction is no problem but I'm having trouble with the descending sort by creation date.

Is this possible via the search API? I've looked through the documentation and haven't found a way to do this yet (although it's possible via the regular Confluence search UI).

At the moment it's looking like I'm going to have to resort to a raw SQL query against the Confluence DB but I'd like to avoid that if possible.

4 answers

1 accepted

2 votes
Answer accepted
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2012

You could use the undocumented AJAX API of the Recently Updated macro to get the list of recently updated pages and comments of a specific space. Here's what the URL could look like:

http://path.to.your.confluence/plugins/recently-updated/changes.action?theme=concise&pageSize=15&spaceKeys=test&contentType=page,comment

You would probably need to add HTTP basic authentication to get the content from outside of Confluence.

Hope this helps

Liam Jones July 26, 2012

Thanks Remo, think I'll go with this one for now. It's not perfect but it does give me a relatively clean/barebones HTML response. :)

1 vote
CharlesH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2012
As an alternative approach you could have a wiki page with the recently-updated or reporting macros to do the 'search' in the way you need. You could then call the renderContent method (SOAP API) for this page to get the data back that you need. Perhaps neater than the Sql option, as this way is guaranteed to get back the same results as the user would see if they were using Confluence I.e. Permissions respected.
Liam Jones July 25, 2012

Thanks for the suggestion Charles. I'd forgotten you could ask for a rendered copy of a page's content. Might be a bit messy to extract what I need from the HTML but good point on the permissions.

I'm guessing it's not actually possible to sort via the search API then? :/

0 votes
Liam Jones July 25, 2012

Outside of Confluence, it's for use by a WCM system on our network.

0 votes
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2012

Do you need to get the list from outside of Confluence or in a plugin?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events