Is it Possible to modify the comment index documents

I’m trying to build a JQL function that lets users find issues that have comments with certain properties that aren’t currently stored in the comments index document.

I’ve been able to find plenty of examples in the Atlassian documentation and elsewhere on modifying the index document for an issue. Reading Index document configuration, I note that IssueProperty is the only available entity-key. Further, Jira doesn’t re-generate comment indexes on a background reindex, and tells customers that configuration changes shouldn’t require a full, stop-the-world reindex:
Understand the index process in Jira server | Jira | Atlassian Documentation

Is there an Atlassian-blessed means of updating the comment indexes? While I reckon it may be possible using Lucene’s API directly, I’d like to know if this is a bad idea for any reason before going down that road.

1 Like

If you’re wanting to change what goes into the Lucene document for a given comment when Jira reindexes that comment, your plugin can implement the com.atlassian.jira.index.CommentSearchExtractor SPI. You would register your implementation via an <entity-search-extractor> element in your plugin XML. Here’s an example of where we did this in the development integration plugin:

    <entity-search-extractor key="devSummarySearchExtractor"
            class="com.atlassian.jira.plugin.devstatus.summary.indexing.DevSummaryIssueSearchExtractor">
        <description>...</description>
    </entity-search-extractor>

Our component was an IssueSearchExtractor rather than a CommentSearchExtractor, but the XML is similar.

That will allow your plugin to make whatever changes it likes to the Lucene document for each comment. Obviously your implementation will need to be highly performant in order not to slow down the overall comment indexing process. Note that this doesn’t affect when the comment gets indexed; it only affects what goes into the document when it does get indexed. You would also need to think about how JQL is going to query whatever you put into the comment index, but that’s starting to get off-topic and you might already have ideas about that anyway.

3 Likes