I'm trying to get at list of pages below a subpage in a space, by using search in the Confluence REST API, but i can't find a description of what query strings the search method accepts.
I've tried to use the syntax for standard Confluence searches, described here:
https://confluence.atlassian.com/display/DOC/Confluence+Search+Syntax
https://confluence.atlassian.com/display/DOC/Confluence+Search+Fields
but the results do not match the results i get when searching via the Confluence web interface.
Is there some documentation describing search queries in the REST interface, or does anyone know how i can search for subpages of a certain page in the page tree?
I'm using Confluence 4.0.4.
Community moderators have prevented the ability to post new answers.
EDIT: I take that back, I just checked with some other Confluence developers and it turns out we do index the ancestorIds field.
Can you give an example of the different results you are seeing in the REST interface compared to the Confluence web interface? As far as I know, you should get identical results from both since they are backed by the same search service and index.
Are you properly encoding your search query? (for example, replacing ":" with "%3A")?
Here's some additional info from the Confluence team:
we don't really consider the contents of the search index to be API
the relevant API methods are the getters on the SearchResult interface
weird - I have no idea where ancestorIds gets indexed. Can't seem to find it in the Confluence source code.
yeah, it's actually done by the pagetree plugin - com.atlassian.confluence.plugins.pagetree.PageHierarchyExtractor
so it's definitely not API, and might cease to work if we removed or replaced that plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As far as i can tell, only basic AND and OR queries work. Anything involving search fields like "title:pagename" or "ancestorIds:12345", which work in the web interface, always yields no results in the REST interface. I've testet using the REST api browser in the administration interface, which automatically url escapes queries, so that shouldn't be the problem either.
To give an example, the query
http://localhost:1990/confluence/rest/prototype/1/search?query=title%3Atest&type=page&groupResults=false&searchParentName=false
Gives me no results, but searching for "title:test" returns 13 pages in my test environment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks like a bug that was introduced in Confluence 4.0. I tried against Confluence 3.5 and it works.
The bug was caused while fixing another bug - against Confluence 3.5 it's not possible to search using the REST API for any content that contains a lucene special character (eg. '*', ':'). This was fixed by automatically escaping everything that gets passed in via the query parameter. So now it's not possible to perform any advanced searching that really does want to use special characters.
I'm still in the process of filing a bug report and seeing if I can fix it myself. I'll post any additional information here when I have it.
As an alternative, the XML-RPC/JSON-RPC and SOAP search APIs should not suffer from this problem - the bug is specified to the REST search service. Could you get by using one of these instead?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's the bug report - https://jira.atlassian.com/browse/CONF-25680
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok. That explains it. I would've preffered to use REST, but i'll try to find another solution. Thank you :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The JSON-RPC interface is pretty good. It's not RESTful, but still very light-weight and easy to work with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JSON-RPC has its own set of problems. However, because of 25680, it is the only way to do complex searches. Please do the needful and fix all 4 bugs, thank you very much, dear Atlassian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.