Re-indexing Jira fields/Jira Issue links

I’ve created fields and Jira issue links manually in Jira and they’re searchable. That’s not the case if I programmatically create fields/Jira Issue links using the Atlassian SDK? Do they have to be re-indexed for them to be searchable via JQL in Jira?
I do have code that works for re-indexing fields but it doesn’t work for Jira issue links. Here’s the code that I’m currently using to re-index Jira issue links.

MutableIssue mutableIssue = ComponentAccessor.getIssueManager().getIssueObject(issue.getKey())
boolean isIndex = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
log.debug(“Reindex issue ${issue.key} ${issue.id}”)
IssueIndexingService IssueIndexingService = (IssueIndexingService) ComponentAccessor.getComponent(IssueIndexingService.class)
IssueIndexingService.reIndex(mutableIssue)
ImportUtils.setIndexIssues(isIndex)

This code appears just before the code that retrieves all the outworks links. There are six links. The one created manually can be retrieved but not the ones created programmatically via the SDK. We are running JIRA v7.2.12. Is there something wrong with the code or can issue links not be re-indexed?