Search APIs

Most of the Open Legislation data APIs include search functionality. We built our search layer using elasticsearch and we aim to provide as much elasticsearch functionality as possible through the APIs.

Every search layer API will have a required request parameter “term” and an optional request param “sort”.


The term parameter takes in an elasticsearch query string.

The simplest way to search is to send a general search term. For example, to search for legislation pertaining to apples, the following query will do the job.


In addition to a simple search term, there are a number of advanced features available. Our search index is generated with data in the same JSON format as the API responses, so any response field that is nested under “result” is fair game for search. Going back to the previous example, a number of resolutions appear in the results for the apples search query. Looking back at the bill response, we see that resolutions are designated by the “resolution” boolean under “billType”. In order to filter resolutions out of the search results, a field query can be chained to the original query using “AND”.


For a full enumeration of query features see the elasticsearch query string syntax.


Searches can be sorted by any number valid response fields. This is accomplished using the sort request parameter, which takes a comma separated string of response fields, each designated with a sort order (“ASC” or “DESC”) separated from the field with a colon.


When sorting using a text field, you must suffix the field name with .keyword e.g. ...&sort=printNo.keyword:ASC... This does not apply to date and time fields, which are indexed in a different manner.

For example, to get the 2013 governor’s program bills in canonical order:


Or, you may want to order them by their status and action date:


Search Response

  "success": true,
  "message": "",
  "responseType": "search-results list",
  "total": 7,
  "offsetStart": 1,
  "offsetEnd": 7,
  "limit": 10,
  "result": {
    "items": [
        "result": { ... },            // A search result
        "rank": 0.3587615191936493    // The ranking of the search result
      ...                           // More search results
    "size": 7