Confluence Adding status field to CQL Edited


I am trying to add "Status" field to CQL using Search extractor in Script Runner. However, I am getting it work. I used following code,

import com.atlassian.confluence.pages.Page
import org.apache.lucene.document.Field
import org.apache.lucene.document.TextField

if (searchable instanceof Page) {
Page page = searchable as Page
String status = page.contentEntityObject.getEntity().getProperties().getStringProperty("Status") as String
document.add(new TextField("status", status, Field.Store.YES))



Am I doing anything wrong here?


I know there is Atlassian KB for developing a plugin

but I don't want to develop a separate plugin. I believe it should be achievable by ScriptRunner.


2 answers

1 accepted

Accepted Answer
0 votes

Problem is fixed after deleting all cache folders such as plugins-cache, plugins-osgi-cache, plugins-temp, journal and index. Restart the application. Rebuilt Content Index after restart. 

1 vote
Stephen Deutsch Community Champion Jan 15, 2018

Hi Suhas,

it sounds like you're trying to build a SearchExtractor. It seems like you're on the right track, but the line 

String status = page.contentEntityObject.getEntity().getProperties().getStringProperty("Status") as String

could probably be simplified to 

String status = page.getProperties().getStringProperty("Status") as String

since page inherits methods from ContentEntityObject.


I think there's three things you need to make sure about:

1. Is the content I'm looking for actually stored in the "status" property?

2. Have I re-built the search index after inserting the script?

3. Do I get results when searching with the recommended syntax ( status : whatever ) in a normal text search?

You may also have to change

document.add(new TextField("status", status, Field.Store.YES))


document.add(new StringField("status", status, Field.Store.YES))


import org.apache.lucene.document.TextField


import org.apache.lucene.document.StringField

Hi Stephen,

Thanks for the inputs.

Yeah, you are right, I will make changes you suggested for simplifying the code.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

1,177 views 4 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you