How to use SearchCount method of Search Service Interface of atlassian 6.2.1?

477 Views Asked by At

I am developing application related to jira. I want count of issues return by the jql query. i got searchCount method in this link but i am not getting how to use this method using instance.

1

There are 1 best solutions below

0
On

The setup should look like this:

    String jqlQuery = "project=ABC"; // insert your JQL query here

    SearchService.ParseResult parseResult = searchService.parseQuery(currentUser, jqlQuery);

    if (!parseResult.isValid())
    {
        // errors in parseResult.getErrors().getErrorMessages()
        throw new MyException();
    }

    com.atlassian.query.Query query = parseResult.getQuery();

    com.atlassian.jira.util.MessageSet validateResults = searchService.validateQuery(currentUser, query);

    if (validateResults.hasAnyErrors())
    {
        // errors in validateResults.getErrorMessages()
        throw new MyException();
    }

With the resulting validated query object, you can then call searchService.searchCount(currentUser, query) to get your issue count.