Hello,
For some of our clients the call to SearchService.search() returns unexpected results. The issue was reported on Jira 9.
For instance, in one case it would return issues with status ‘closed’ even though the jql used in the search was specifying “status != Closed”:
Example of jql:
jql=( (project = YYY AND sprint in openSprints() and issuetype = Sub-task and labels = YYY and status != Closed) )
and the status of some the issues returned by that query:
IssueConstantImpl[[GenericEntity:Status][sequence,518][statuscategory,3][name,Closed][iconurl,/images/icons/final_closed.gif][description,The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.][id,6]]
This does not happen all the time and could not detect a pattern that could explain the issue.
NOTES:
- The same issue happens if the jql query is saved and the filter id used as jql (jql=filer=id)
- However, this never happens if we use the REST api /rest/api/2/search?jql=
I was hoping someone could notice anything wrong with the code we are using (which looks something like this):
private final JiraThreadLocalUtilImpl jiraThreadLocalUtil = new JiraThreadLocalUtilImpl();
private final SearchService searchService = ComponentManager.getInstance().getComponent(SearchService.class);
void search(ApplicationUser user, String jql) {
jiraThreadLocalUtil.preCall();
final SearchService.ParseResult parseResult = this.searchService.parseQuery(user, jql);
final SearchResults<Issue> searchResults = this.searchService.search(user, parseResult.getQuery(), new PagerFilter(0, PagerFilter.getUnlimitedFilter()));
for (Issue issue : searchResults.getResults()) {
...
}
jiraThreadLocalUtil.postCall(log);
}