Log BadRequest responses from elasticsearch

This lets us see the body of the response, which contains details of
what went wrong.
Merge pull request #261 from alphagov/log-elasticsearch-400s

Log BadRequest responses from elasticsearch
Add a parse_query_string helper

This uses Rack's KeySpaceConstrainedParams to get protection from
callers making requests with very large numbers of keys, but otherwise uses much
simpler logic than the normal query parsing.  Parameters are always
returned as lists of values, and square bracket special-syntax handling
is restricted to stripping off trailing "[]" from parameter names (so
that we support ruby clients which add that automatically for values
which are lists).
Don't require [] on unified_search parameter names

So that callers don't get a bad request error if they forget to use []
on some parameters, or if they use it on other parameters, strip off the
[] at the end of parameter names, and keep all values of parameters
passed to unified_search, presenting them as lists to the
SearchParameterParser.

This makes it easier to hand-construct queries, easier to call rummager
from languages other than Ruby, and should reduce the number of emails
we get from errbit due to incorrect use or omission of [] when
constructing parameters for calls to rummager.

Returns appropriate explanatory messages if parameters which should
occur at most once are repeated.

As a bonus, parameters such as "fields" or "debug" which take comma
separated lists of values can now be supplied in either that form, or as
repeated instances of the parameter.
Return 422 for validation errors on unified_search

This follows the policy decision in
https://github.com/alphagov/styleguides/blob/master/api.md
Merge pull request #263 from alphagov/validation_fails_return_422

Return 422 for validation errors on unified_search
Avoid an empty msearch call when no facets

When requesting facet examples if there are no facets, we need to avoid
making a call to elasticsearch's msearch endpoint, because that returns
a 400 error if given an empty list of queries to run.
Rename AAIB Reports schema to report

Rummager was using the document_type to find the schema, but our schema
has reports when it should be report.
Merge pull request #265 from alphagov/rename-aaib-reports-schema

Rename AAIB Reports schema to report
Fake a slug for sector documents

Specialist sector documents don't come from whitehall and so they don't
have a slug in search.  Panopticon constructs the link field from the
slug (held in panopticon) by adding a '/' prefix, so rather than do the
work now to add a slug and reindex the sectors, we construct a slug
field for the cached sector results in SpecialistSectorRegistry by
removing this '/'.

If the slug field is added in future, this hack can be removed, but it
shouldn't break anything if it isn't.

Fixes https://www.pivotaltracker.com/story/show/74843014
Merge pull request #266 from alphagov/fix_expand_specialist_sectors

Fake a slug for sector documents
Merge pull request #262 from alphagov/nicer-parameter-parsing

Don't require [] on unified_search parameter names
Merge pull request #264 from alphagov/facet_examples_no_examples_fix

Avoid an empty msearch call when no facets
Handle param parsing with missing parameters
Merge pull request #267 from alphagov/fix-parameter-parsing-with-missing-params

Handle param parsing with missing parameters
Use CGI::parse to parse query parameters

This is nicer (less code) than using our hand-rolled parser, though
CGI::parse's code is pretty similar to what we were doing.

This loses the use of Rack's KeySpaceConstrainedParams to limit the
number of parameters, but this is mainly useful for preventing DOSes on
post requests, and we only expose GET endpoints to the public, so this
should be fine.
Rename examples object to example_info in response

Previously, responses containing facet examples had a "examples" object,
which contained a key called "examples" which actually contained the
examples.  This was confusing and error prone.

Instead, name the outer object "example_info", and just name the inner
list of the actual examples "examples".  Something like:

    {"example_info": {"total": 5, "examples": [ {...} ] } }
Merge pull request #269 from alphagov/improve-facet-examples

Rename examples object to example_info in response
Merge pull request #268 from alphagov/use-cgi-parse

Use CGI::parse to parse query parameters