This inverts the monkeypatch so that we can continue to work with
ElasticUtils 0.90, but use elasticsearch-py >= 1.0. That makes things a
lot easier going forward.
Fixes#261
* Add more Elasticsearch versions to the Travis matrix.
* ElasticUtils may not work with Django 1.7. At a minimum, we know that
tests don't pass. For now, restricting the Django version to <1.7.
This makes some pretty big changes.
1. .values_list() and .values_dict() will now **always** send the
"fields" property to ES. If you don't specify any field arguments,
then "fields=[*]". If you do specify fields arguments, then it'll
be that list of fields.
2. Elasticsearch 1.0 changed the shape of what gets returned--all
values are lists when you specify the "fields" property. To
make Elasticsearch 0.90 and Elasticsearch 1.0 consistent, we
now convert any non-list values into list values for Elasticsearch
0.90.
Wait, wat? Prior to this commit, you'd have the following:
# Elasticsearch 0.90
>>> list(S().values_list())
[(501, 'frank'), (602, 'sam')] # values are ints and strings
>>> list(S().values_list('id', 'name'))
[(501, 'frank'), (602, 'sam')] # values are ints and strings
# Elasticsearch 1.0
>>> list(S().values_list())
[(501, 'frank'), (602, 'sam')] # values are ints and strings
>>> list(S().values_list('id', 'name'))
[([501], ['frank']), ([602], ['sam'])] # values are all lists
After this change, we have this (assuming id and name fields are stored):
# Elasticsearch 0.90
>>> list(S().values_list())
[([501], ['frank']), ([602], ['sam'])]
>>> list(S().values_list('id'))
[([501], ['frank']), ([602], ['sam'])]
# Elasticsearch 1.0
>>> list(S().values_list())
[([501], ['frank']), ([602], ['sam'])]
>>> list(S().values_list('id'))
[([501], ['frank']), ([602], ['sam'])]
If you plan to call .values_list() and .values_dict() with no arguments,
you must add "store: True" to your mappings for the fields you want to
get back.
In order for ElasticUtils to work for both Elasticsearch 0.90 and
Elasticsearch 1.0 using elasticsearch-py 0.4.5, we need to do some
monkey-patching of elasticsearch-py.
In this case, calling Elasticsearch.client.bulk() returns an 'ok' field
with ES 0.90 and a 'status' field with ES 1.0. This patch sets the 'ok'
field based on the 'status' field so that the bulk indexing
infrastructure in elasticsearch-py 0.4.5 is testing the right thing and
not raising BulkIndexingErrors.
Fixes#241