Add loadFixture test helper using mongoimport

Shelling out to mongoimport(1) is much faster than trying to do a bulk
insert from node. This can be used in tests to load up json files
produced by mongoexport(1).
Enable elasticsearch for travis builds
Fix running tests with elasticsearch
Add tests for model search interface

Model level testing for the elasticsearch integration. The setTimeout
call in the refreshElasticsearchIndex call is necessary because
elasticsearch gives an error about a missing index if you try to refresh
immediately.
When documents are removed delete from the index

This ensures that deleted documents don't appear in search results.

Only pre middleware takes a `next` function, post middleware simply
takes the document, which we can use directly for indexing and deleting.
Ensure mongoose middleware always gets called

Instead of calling methods on the model class we need to call them on
the model instance so the middleware hooks get run.
Make elasticsearch tests more robust

Rather than performing a search for a document, simply do a GET request,
which will always return a document which has been successfully
inserted, unlike searching for it, which only works after refreshing an
index.
Whitelist allowed elasticsearch parameters

Only allow the `q` parameter to be specified though the params object
(and therefore the query string).

Prevents people from searching other instances and types though the
search API.
Add pagination for API search results

Rather than expose the whole elasticsearch uri search API [1] to the
user, we just allow them to specify the `q` parameter, which still
offers a rich query API, then layer our own pagination on top.

This gives an example of what the pagination query string API might
look like for other resources when we get round to doing #8. The
parameters are called `per_page` and `page` to allow specifying the
number of results to return and the page of results to return.

[1] http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html
Always run the toJSON filter

Even if the fields configuration is missing we want to run the filter so
"internal" fields that start with an underscore are removed before the
document is indexed.
Keep track of how many documents have been reindexed

When running the `reIndex` method, keep track of how many documents have
been indexed and return it to the callback. This is used by popit's
reindex command to report how many documents were indexed back to the
user.
Rename toJSON transform function

This makes it clearer that the toJSON method isn't solely responsible
for doing the JSON transformation.
Add module for reindexing an instance into elasticsearch

Takes a database name, connects to that database and then indexes the
documents from each popolo collection into elasticsearch. If a
document hasn't been indexed before it will be created, otherwise it
will be updated based on its _id field.

This also exposes the method on the main module so the popit UI can
require it and re-index all of the instances at once.
Add elasticsearch to README instructions
Pass any errors through to es-* events

If there is an error indexing or removing a document then we want to be
able to access that error from any listeners for the es-* events.