About Jira modules
Customer portal
Project settings UI locations

Entity index extractor

Available:

Jira 10.4 and later.

Purpose

The entity index extractor plugin module allows plugins to add fields to issues, comments, work logs, or change history during indexing. These fields can be queried via the Search API.

Configuration

The root element for the entity index extractor plugin module is entity-index-extractor. It requires the following attributes for configuration:

Name

Description

key

The unique identifier of the plugin module.

class

The fully qualified extractor class name.

You can add multiple extractors as long as they have distinct keys.

Configuration example

To register an extractor, place the following code sample in atlassian-plugin.xml:

1
2
<entity-index-extractor
    key="issueIndexExtractor"
    class="com.atlassian.jira.dev.reference.plugin.extractor.DefaultIssueIndexExtractor" />

The DefaultIssueIndexExtractor extractor renders the summary content and stores it into the mirror_summary field. The sample demonstrates:

  • How to define a field (MIRROR_SUMMARY).
  • How to add a field to the index schema.
  • How to index a field (MIRROR_SUMMARY).
1
2
package com.atlassian.jira.dev.reference.plugin.extractor;

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.search.Field;
import com.atlassian.jira.search.entity.IssueIndexExtractor;
import com.atlassian.jira.search.field.AnalyzedTextField;
import java.util.Collection;
import java.util.Set;

import com.atlassian.jira.search.field.FieldValueCollector;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.StringUtils;

public class DefaultIssueIndexExtractor implements IssueIndexExtractor {
    static final AnalyzedTextField MIRROR_SUMMARY = AnalyzedTextField.builder("mirror_summary")
            .indexed()
            .stored()
            .build();

    @Override
    public Collection<Field> getFields() {
        return Set.of(MIRROR_SUMMARY);
    }

    @Override
    public void indexEntity(final Context<Issue> ctx, final FieldValueCollector collector) {
        final Issue issue = ctx.getEntity();
        final String mirroredSummary = issue.getSummary() + StringUtils.reverse(issue.getSummary());
        collector.add(MIRROR_SUMMARY, mirroredSummary);
    }
}

Implement an extractor

Each entity has a dedicated interface you can implement:

  • Issue: IssueIndexExtractor
  • Comment: CommentIndexExtractor
  • Worklog: WorkLogIndexExtractor
  • ChangeHistoryGroup: ChangeHistoryIndexExtractor

getFields method

All fields need to be added to the schema so that the Search API can validate them. The Search API calls the getFields method to define the schema. All fields that can potentially be indexed by your extractor should be returned.

indexEntity method

The Search API will provide your extractor with the entity being indexed in the Context parameter of the indexEntity method.

See also

Entity properties allow plugins to add key/value stores to Jira entities without writing any code. These values can be indexed by Jira and queried via REST API or JQL.

Rate this page: