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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,639,514
Community Members
 
Community Events
196
Community Groups

How can I filter my Confluence search by page properties?

Hi,

Is there a way to perform a search with CQL and filter for page properties?

I know the unofficial REST interface /rest/masterdetail/1.0/detailssummary/, but with this interface I can only display the properties and not filter by them.

/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage&spaceKey=TEST&label=hello&countLikes=true&headings=...

 I can't find anything about it under the official REST API : https://docs.atlassian.com/ConfluenceServer/rest/6.13.0/.

2 answers

Hi,

if you want to access the service on the server side, you can use the same 'unofficial' API:

https://bitbucket.org/atlassian/confluence-masterdetail-plugin/src/f4da6483b21a/plugin/src/main/java/com/atlassian/confluence/?at=master

You find the relevant interfaces and model under com.atlassian.confluence.plugins.pageproperties.api

Example code (groovy, written for the Scriptrunner console):

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.plugin.ConfluencePluginManager
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.pages.Page
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl

// For accessing dynamic plugin classes
ConfluencePluginManager confluencePluginManager = ComponentLocator.getComponent(ConfluencePluginManager)

// Get test page using hard-coded page-ID...
def pageManager = ComponentLocator.getComponent(PageManager)
def testPage = pageManager.getPage(12345678)
def pagePropertyService = ScriptRunnerImpl.getPluginComponent(confluencePluginManager.getDynamicPluginClass('com.atlassian.confluence.plugins.pageproperties.api.service.PagePropertiesService'))
def report = pagePropertyService.getReportFromContent(testPage)

// All page property macro (not just page property macros with specific ID:
def macros = report.getAllMacroInstances() /*List<PagePropertiesMacroInstance>*/

// Iterate and collect maps
def map = [:]
macros.each {
map << it.getPagePropertyReportRow() /*Map<String, PageProperty>*/
}
// Now you can access specific properties in the map, value is a PageProperty object
"""
report=${report.toString()}<br/>
macros=${macros.toString()}<br/>
map=${map.toString()}<br/>
"""

Similar concept, but probably using nice features like autowiring, etc. should work for JAVA plugins. With custom CQL functions you can add your own CQL filters using page property service (not tested). The page properties use a lot of XML parsing (see DetailsMacroBodyHandler), so have an eye on the performance.

Christian

Hauke Hörhold
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.
Jun 25, 2019

Hello Christian, thank you for this nice reply!

Could you tell me more detailed how to add my own CQL filters using pagePropertyService?

Or is there a manager or something with which I can easily read the page properties?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events