* changes some of the formatting so that we get interlinking for
free
* add a bunch of things to the API section
* remove "verbose content" that duplicates content in the docstrings
and in some cases was out-of-date or just plain wrong
Adds a bunch of docstrings.
MappingType should be overridden. The get_indexes and
get_mapping_type_name methods were returning default values that
didn't make any sense. Better to raise NotImplementedError.
Previously you could only force an S to execute the search as a
side effect of requesting something out of it (count, facet_counts,
an iterable of results). This allows you to execute the search
and get back a SearchResults instance which has some interesting
things on it like a .results property which has the complete
ES response body.
pyelasticsearch refresh doesn't take a timeout, so nixing that.
Additionally, it's more flexible if Indexable had its own get_es()
class method that it defaults to using that can be easily overridden.
So I tweaked that code a little.
If django isn't installed, we want all the django tests to get skipped.
This fixes an issue with get_es not existing because it doesn't get
imported because django isn't installed.
* nixed max_retries because I personally think it's got a confusing
name and, like revival_delay, it's probably not something someone is
going to use often
* added caching of ElasticSearch object creation with tests
* nix pyes things
* update to pyelasticsearch things
* fixes MLT so it works with pyelasticsearch (requires fixes that
should be in pyelasticsearch 0.3 when that gets released)
* changes MLT fields argument to mlt_fields
* nixes all the dump curl code
* cleans up imports
* fixes defaults so that S defaults to searching all indexes and
all doctypes
* adjusts errors so they all derive from ElasticUtilsError
* cleans up get_es() and S.get_es() so they're correct
* add DeprecationWarning for deprecated things
* update test code for MLT
In elasticutils.contrib.django:
* ditch the thread-local caching of ElasticSearch objects (we'll
implement something better soon since pyelasticsearch's ElasticSearch
objects are thread-safe)
* removed statsd code from the django-related code
* change ES_HOSTS to ES_URLS
* update index method (need to add a new bulk_index method)
* update test code for django-related bits
The problem is this one:
https://github.com/elasticsearch/elasticsearch/issues/2205
This was a bug in ElasticSearch 0.19.9 that was fixed in 0.19.10 so
I added a note to the docs stating ElasticUtils doesn't work with
ElasticSearch 0.19.9.
If django is not installed, then we don't import get_es and then this
code fails. But we don't need the get_es method on QueryTest anyhow,
so this nixes it.
This will set up the Django environment so the Django-specific tests can
run. If Django is not present, the setup will be skipped and the tests
will be run normally. The testsuite will skip any Django-specific tests
in this case. This simplifies running the full test suite.
The problem here is that it's logging as an error and then re-raising.
That's kind of irritating. It's better to just let it propagate back
to the application and let it do whatever it wants to do.
Amongst other things, this is less spammy with sentry.
All the S.get_indexes() returned a list of indexes except the one
in Django contrib which could return a basestring or a list of
indexes.
Ditto for S.get_doctypes().
This fixes that, adds docs, and adds tests.
text_phrase queries are really just text queries, so they require the
same value_key name. This fixes that and also writes a test for boosts
that runs through ES so we can verify it doesn't kick up a
SeachPhaseWhateverThingy.
This tweaks the es_required_or_50x decorator to handle other ElasticSearch
errors and also improves the documentation. It also allows for template
overrides and nixes the msg arguments--they seemed less flexible.
Note: These decorators have no tests in the test suite, yet.
* add handling for date_histogram in facet_counts
* fix facet_counts to raise an exception rather than silently act
dumb if it doesn't recognize the _type
tl;dr: This is a big rewrite with huge API-breaking changes.
This replaces the old model-type system with the new MappingType
system. This adds a degree of separation between models (traditionally
stored in a db) and documents (stored in ElasticSearch).
Untyped S works just like in v0.4 with the exception that if you
don't specify values_dict or values_list, you now get back a list
of DefaultMappingType which are slightly more useful than dicts.
You can now create an S typed by a MappingType which makes it easier
to specify the index and doctype, but also allows you to tie
business logic to search results and also tie that back to db
objects in a lazy-loading way. For example, say you had a description
field and wanted to have a truncated version of it::
class MyMappingType(MappingType):
def description_truncated(self):
return self.description[:100]
res = list(S(MyMappingType).query(description__text='stormy night'))[0]
print res.description_truncated()
Also, inextricably linked with this commit is a minor rewrite of the
test suite. They should run faster now, are better organized, and should
be easier to write in the future. test_django.py doesn't look like it
was written by a shrewdness of apes any more.
Also fixed a bug where `fields` was affected by ``values_list`` and
``values_dict`` calls---the two need to be separated.