Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Rest API call to search content in a page and it's children

Venkat P February 5, 2019

I have a Wiki Page and a lot of children and grand children underneath it. Using the Rest API, I would like to implement a Search feature that is similar to Confluence Wiki.

Upon each keypress in the input search box, I would like to make an API call with the Parent Page Id in it, and it should bring up Wiki Page Titles that match the content I am searching that are children, grand children or N levels deep, but only belong under that Page Id.

The following API Call searches a space, but not sure how to incorporate a page Id instead of entire space.

/rest/api/content/search?limit=10&cql=space={RGBY}+and+text~{"getting%20 started"}+and+type=page

Any suggestions?

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 15, 2019

Hello Venkat,

Thank you for providing detail into what you want to develop. As you are doing already, your best bet is to use CQL to your advantage in this. The endpoint I would suggest you use is GET /rest/api/search. With the application of CQL to filter based on parent, this should allow you to search all pages of the parent based on your text string in the search. Here is what an example would look like:

http://localhost:8080/confluence/rest/api/search?cql=parent=123+and+text~{"getting%20 started"}+and+type=page

Another option would be to use your API endpoint you already have along with your CQL statement and append the parent page ID you wish to search within.

For more information about CQL fields, please review CQL field reference.

I hope this proves helpful and provides some guidance on creating your custom search.

Regards,
Stephen Sifers

Venkat P March 2, 2019

It looks like if I specify the parent CQL parameter, it only searches it's immediate children, but not it's grandchildren. Are there any suggestions to search in any level under a parent?

Like Stephen Sifers likes this
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 6, 2019

Hello Vankat,

This is a great follow up question when you specify a parent within CQL, it should return results of all child pages (to include a grandchild.) With this said, could you please let us know the CQL you're using to search under a parent and we may test it out on our end?

Along with this, we need to know which Confluence Server version you're on so we may get accurate results.

We look forward to your response so we may find a solution for you.

Regards,
Stephen Sifers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events