Hello,
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 https://developer.atlassian.com/server/confluence/adding-a-field-to-cql/
but I don't want to develop a separate plugin. I believe it should be achievable by ScriptRunner.
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.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may also have to change
document.add(new TextField("status", status, Field.Store.YES))
to
document.add(new StringField("status", status, Field.Store.YES))
and
import org.apache.lucene.document.TextField
to
import org.apache.lucene.document.StringField
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen,
Thanks for the inputs.
Yeah, you are right, I will make changes you suggested for simplifying the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.