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.
* tweaks the MLT class so that s isn't required anymore
* adds an es argument
* adds documentation
* adds two more tests to make sure the s vs. index/doctype works
correctly
These two defaults were wrong--they're both plural and should be a list
of strings. Other values are wrong.
This fixes that and also fixes a bunch of tests that broke because of it.
* overhauls SearchMixin to be more useful and flexible but continue to
have useful defaults
* this overhauls a lot of the documentation for the contrib.django stuff
and makes more of it correct