Hi there,
I’m currently migrating our app to be compatible with Jira 11. I’m following the official Atlassian documentation here:
Search API deprecations and upgrade guide for Jira 11
However, I couldn’t find any clear reference or example usage for the new IssueDocumentSearchService.
In our existing implementation, we are using the following classes:
import com.atlassian.jira.issue.search.SearchProvider;
import com.atlassian.jira.issue.search.SearchQuery;
// Example usage:
searchProvider.search(SearchQuery.create(query, user), collector);
Could anyone please share:
-
A code example or documentation link for how to use IssueDocumentSearchService in Jira 11?
-
The equivalent way to replace the searchProvider.search(...) call with the new API?
Thanks in advance for any guidance!
import com.atlassian.jira.search.response.SearchResponse;
import com.atlassian.jira.search.issue.IssueDocumentSearchService;
import com.atlassian.jira.web.bean.PagerFilter;
private static final int MAX_ISSUES_RETURNED = 150;
private static final PagerFilter PAGER_FILTER = new PagerFilter(MAX_ISSUES_RETURNED);
List<String> collectFieldFromFeatures(Issue epic, String fieldId) {
SearchResponse searchResponse = null;
try {
searchResponse = issueDocumentSearchService.search(
DocumentSearchRequest.builder()
.searcher(authenticationContext.getLoggedInUser())
.jqlQuery(getQueryForEpic(epic))
.overrideSecurity(true)
.build(),
PAGER_FILTER);
} catch (SearchException e) {
log.error(e.getMessage(), e);
}
if (searchResponse == null) {
return Collections.emptyList();
}
return searchResponse.getHits()
.stream()
.map(hint -> hint.getDocument()
.getString(fieldId)
.orElse(null))
.filter(Objects::nonNull)
.toList();
}
private Query getQueryForEpic(Issue epic) {
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
return builder.where().defaultAnd()
.customField(fieldsProvider.getEpicLinkCustomField().getIdAsLong())
.eq(epic.getKey())
.issueType(issueTypesProvider.getFeatureIssueType().getName())
.status().notEq("Aborted").buildQuery();
}
fieldId something like “key” (it stores issue key)