Skip to end of metadata
Go to start of metadata

To create and run a search using the Jira API, obtain a SearchRequest object and addParameter's to it.

 
SearchRequest sr = new SearchRequest(remoteUser);
sr.addParameter(new StatusParameter( String.valueOf(IssueFieldConstants.RESOLVED_STATUS_ID) ));
sr.addParameter(new DateParameter(DocumentConstants.ISSUE_UPDATED, EntityOperator.GREATER_THAN_EQUAL_TO, start));
sr.addParameter(new DateParameter(DocumentConstants.ISSUE_UPDATED, EntityOperator.LESS_THAN_EQUAL_TO, end));
sr.addParameter(new ProjectParameter(projectid));
resolvedCount=searchProvider.searchCount(sr, remoteUser); 

If the Jira search API doesn't do what you need, you may need to extract issues from a search and loop over them.

 
Collection issueList=searchProvider.search(sr,remoteUser);
Iterator issIt=issueList.iterator();
while (issIt.hasNext()){
            GenericValue issue = (GenericValue) issIt.next();
            Map myIssue = issue.getAllFields();
//log.debug("iss="+issue.getAllFields()+","+issue.getAllKeys());
log.debug("check issue "+myIssue.get("key")+" res= "+myIssue.get("resolution"));
}

Things like creation date are in the main issue object's map, see Issue Properties, resolved dates etc. are in the issues change log, see JiraIssueChangeHistory.

Labels:
  1. Jun 23, 2005

    You can also use sr.getQueryString() to create an URL of the form:

    <server>/secure/IssueNavigator.jspa?reset=true&mode=hide&<sr.getQueryString()>

    to list the issues in the Issue Navigator screen.

  2. Jun 23, 2005

    Once you have an issue, you can lookup the value of a custom field as follows:

    CustomField severity = customFieldManager.getCustomFieldObjectByName("Severity");

    Object severityValue = severity.getValue(issue);

  3. Jun 24, 2005

    I am being a little lazy here, but any suggestions on how to create a search using a custom field?

  4. Oct 17, 2005

    How would one search for a particular "Summary" or "Description?"

  5. Oct 18, 2005

    Mike,

    You should be able to do something like the following:

    Or if you wish you strings to be stemmed you can use a FreeTextParameter.

    Cheers,
    Nick

  6. Nov 19, 2005

    I have a select list custom field.  What is the proper searchparameter to use for searching a select list?  I tried FreeTextParameter, but that did not seem to work.

    Thank you,
    Mike

  7. Nov 20, 2005

    Mike

    You should use the StringParameter search parameter

    Cheers

    Mark C

  8. Nov 03, 2006

    Is it possible to search for votes on issues? For example get all issues where the number of votes is greater than 10?
    I could not find a SearchParameter for this.

     Thanks,
      Matthias.

  9. Sep 21, 2010

    Is there a way to make a copy of a filter for another user? I'd like to do so via a Groovy script if possible.

    Thanks!