Bugzilla:BzAPI:Search

From MozillaWiki
Revision as of 13:36, 4 October 2009 by Gerv (talk | contribs) (→‎Changes)
Jump to navigation Jump to search

This page defines the URL parameter interface for searching for bugs using the HTTP API (/bug GET). This was the last thing developed before 0.1 and is a wide area, so please be particularly on the lookout for bugs (e.g. searches which don't return what you expect).

Single Value, Multiplicable

For the following fields, specify any number of individual discrete values as separate URL parameters with identical keys.

Fields: classification, component, op_sys, platform, priority, product, resolution, severity, status, target_milestone, version

E.g. component=XML&severity=critical&severity=blocker

Text Fields

For the following fields, specify some text to search for along with a $FIELDNAME_type parameter with a value from the list of types.

Fields: comment, keywords, summary, url, whiteboard

E.g. summary=Flash%20crash&summary_type=contains_all_words

They keywords search will complain if your words are not valid keywords.

Person Fields

Specify up to two strings, as email1 and email2, and then specify the fields in which to search for those strings (booleans - set to 1 if wanted), and the type of search to do (emailN_type) from the list of types. You can specify multiple email addresses, comma-separated.

Fields: email1, email2, emailN_type, emailN_assigned_to, emailN_qa_contact, emailN_reporter, emailN_cc, emailN_comment_author

E.g. email1=fred@example.com,wilma@example.com&email1_type=equals_any&email1_assigned_to=1&email1_qa_contact=1

Bug ID

Specify id'=<comma-separated list>, and an id_mode of either include or exclude. Note that this field does not support aliases.

E.g. id=3,4,5,6&id_mode=include

Deadline

Specify a range with deadline_after and deadline_before. (Note: implementation is actually 'on or before' and 'on or after'; this may change, so be warned).

E.g. deadline_after=2008-08-08&deadline_before=2009-09-09

Changes

You can also ask for bugs that have changed in a particular date range, using changed_after and/or changed_before. You may additionally specify that a particular field has changed in that time using changed_field, and also optionally set changed_field_to_value to specify the new value. If you don't specify a field, it tells you whether last_change_date is in the range given.

There is a magic value for "changed_field" of "[Bug Creation]" which allows you to look for bugs filed between certain dates. XXXchange to creation_time

E.g. changed_after=2008-08-08&changed_before=2009-09-09&changed_field=priority&changed_field_to_value=P1

Boolean Charts

The Bugzilla "boolean charts" mechanism is the way to construct more complex queries, or to search on other fields which do not have their own dedicated parameters (e.g. time tracking fields, attachment fields, flags, history, groups and related bugs). Boolean chart parameters are passed through unchanged, apart from translating any new field names and new type names into the ones Bugzilla understands natively.

The parameters for each triple are fieldA-B-C, typeA-B-C and valueA-B-C, where A, B and C are integers beginning at 0.

  • A is the number of the chart; each chart is an entirely separate condition on the search.
  • Within an A grouping, all charts with the same B are ANDed together.
  • Within a B grouping, all charts with the same C are ORed together.

Or, to put it another way, with an example:

0-0-0 && 1-0-0 && (2-0-0 && 2-1-0) && (3-0-0 && (3-1-0 || 3-1-1 || 3-1-2))

Every field on the bug object (except ref, token and work_time, which is Submit Only) can be used with the boolean charts.

A Note on Plurality: some fields on the Bug object whose values are arrays are linguistically plural, but search only applies to a single instance. The field names for search in these cases are in the singular. This applies to: comments, attachments, flags, and groups.

You may search all attachment fields (except encoding) by specifying a field of "attachment.<fieldname>". Additional field values you can use are:

Name Description
comment.is_private Comment privacy
comment.author Person adding a comment
content Full text of bug; use with special 'matches' type
idle Time since bug was last changed by anyone, in days
flag Name of a flag
flag.requestee Person of whom a flag set is requested (name)
flag.setter Person who set a flag (name)
assignee_idle Time since bug was last changed by assignee; postfix number with h/d/w/m/y to specify units

<a name="types"></a> Type values you can use are:

Name Description Value Format Notes
equals is equal to
not_equals is not equal to
equals_any is equal to any of the strings
contains contains the string
not_contains does not contain the string
case_contains contains the string (exact case)
contains_any contains any of the strings
not_contains_any contains none of the strings
contains_all contains all of the strings
contains_any_words contains any of the words
not_contains_any_words contains none of the words
contains_all_words contains all of the words
regex matches regular expression (As interpreted by DB)
not_regex does not match regular expression (As interpreted by DB)
less_than is less than Integer or Timestamp
greater_than is greater than Integer or Timestamp
changed_before changed before Timestamp
changed_after changed after Timestamp
changed_from changed from
changed_to changed to
changed_by changed by name of User
matches matches Full text of bug contains the string; use only with special 'content' field