This is for any Atlassian Confluence developers or contributors reading my blog. I am trying to develop a simple plugin and wanted to use the Confluence Search (v2) API but couln’t find much in the way of documentation or examples.
So I posted a question to the Confluence Forum but got no reply in three days :(. Should anyone be able to help me, the forum thread is here but I am also reposting here the text of the question:
I’m looking for examples and guidance in using the Search (v2) API in Confluence, specifically from a plugin.
I got hold of a SearchManager via Dependency Injection and obtained some results with code like the following
SearchQuery query = ...; Search search = new Search(query, null, null); SearchResults results = this.searchManager.search(search);My problem is that I have no idea about which implementation of the SearchQuery interface to use and in particular how to specify a phrase to search for, since no subclass seems to provide for a way to set a query term.
Thanks in advance.


We probably should have mentioned this in the release notes, but the v2 search API is a work in progress at the moment. It’s something I worked on during the 2.8 cycle with the view to improve search in 2.9+, but it’s not actually used inside Confluence yet!
Keep doing search the old way for now.
Thanks for your reply, Charles. However, I’m not much better off even with your suggestion. Having never written code to do searches in Confluence, I have no idea what the “old way” is. Do you have any tutorials or samples?
Think I might have started along the right path by reverse-engineering some code from the Advanced Search plugin. At least, I have some results and no errors so far.
The “old way” Charles refers to is with the SmartListManager and ListQuery objects. If you look at the SiteSearchAction and SearchQueryBean in the Confluence source release, you can see how we do it in Confluence in 2.8.