DocValuesField "sr_num_atch" appears more than once in this document

If you have upgraded Jira to version 8.10 or above you may see an error like this when re-indexing with ScriptRunner installed:

Problem Error
DocValuesField "sr_num_atch" appears more than once in this document (only one value is allowed per field)

This error will not show for everyone who upgrades. The problem will only show for users who have ended up with multiple issueFunction fields as a result of past bugs. This is a field added by ScriptRunner for JQL functions and if there are duplicates, they will not show on the custom fields admin area.

To see if there are multiple versions of this indexer field added you can run this script in the Script console:

Count of "ScriptFunctionSearchIndexer"
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.jql.ScriptFunctionSearcher

def searcherManger = ComponentAccessor.getComponent(IssueSearcherManager)
def issueFunctionSearcherCount = searcherManger.allSearchers.count { it instanceof ScriptFunctionSearcher }

"Searcher count: ${issueFunctionSearcherCount}"

Example problem output:

Searcher count: 6

If the script returns a "Searcher" count higher than 1 (as shown above) then you have multiple issueFunction fields added to your server. The issueFunction field should only be added once (issueFunction is a field added by scriptrunner to allow JQL functions to work). This has not caused any problems up until Jira 8.9 but a change in the implementation of how field indexers are tracked in Jira 8.10 means that Jira will now register indexers for each issueFunction field. This is what causes the indexing problem with the sr_num_atch index field being added multiple times.

Please take a backup of your Jira Server before running the next script. The script deletes the additional IssueFunction fields found on your Jira instance

To fix it please run the following script in script console:

IssueFunction field Duplicate Removal Script
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.jql.ScriptFunctionSearcher

def customFieldManager = ComponentAccessor.customFieldManager
def issueFunctionFields = customFieldManager.getCustomFieldObjectsByName("issueFunction")
def fieldsToBeDeleted = issueFunctionFields.size() - 1

log.error("Fields to be deleted: ${fieldsToBeDeleted}")

if (fieldsToBeDeleted) {
    issueFunctionFields.takeRight(fieldsToBeDeleted).each { field ->
        log.error("Successfully removed custom field: ${}")

    log.error("Successfully removed ${fieldsToBeDeleted} custom field(s)")

After running this script, and switching to the log tab of the script console you should see the following on the last line:

Successfully removed n custom field(s)

If that's the case then you should perform a full reindex at a time convenient for you. Please let us know afterwards if the issue was fixed and you were able to successfully reindex without seeing the errors in the log mentioning sr_num_atch like when indexing before.