Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What is the format of queries for search in the Confluence REST API?

Kristian Andersen June 5, 2012

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.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 6, 2012

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")?

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 6, 2012

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

Kristian Andersen June 6, 2012

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.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 7, 2012

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?

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 7, 2012
Kristian Andersen June 7, 2012

Ok. That explains it. I would've preffered to use REST, but i'll try to find another solution. Thank you :)

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 7, 2012

The JSON-RPC interface is pretty good. It's not RESTful, but still very light-weight and easy to work with.

Sergey Svishchev
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.
April 24, 2014

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.

TAGS
AUG Leaders

Atlassian Community Events