fix undefined variable when raising the 'unrecognised lookup' error

This commit is contained in:
Matt Westcott 2014-10-01 16:48:45 +01:00
parent ba9f580ef0
commit c21f148071
2 changed files with 7 additions and 1 deletions

View file

@ -210,7 +210,7 @@ class ElasticSearchQuery(object):
}
}
raise FilterError('Could not apply filter on ElasticSearch results: "' + field_name + '__' + lookup + ' = ' + unicode(value) + '". Lookup "' + lookup + '"" not recognosed.')
raise FilterError('Could not apply filter on ElasticSearch results: "' + field_attname + '__' + lookup + ' = ' + unicode(value) + '". Lookup "' + lookup + '"" not recognised.')
def _get_filters_from_where(self, where_node):
# Check if this is a leaf node

View file

@ -31,6 +31,12 @@ class TestElasticSearchBackend(BackendTests, TestCase):
with self.assertRaises(FieldError):
results = list(self.backend.search("Hello", models.SearchTest, filters=dict(id=42)))
def test_filter_with_unsupported_lookup_type(self):
from wagtail.wagtailsearch.backends.elasticsearch import FilterError
with self.assertRaises(FilterError):
results = list(self.backend.search("Hello", models.SearchTest, filters=dict(title__iregex='h(ea)llo')))
def test_partial_search(self):
# Reset the index
self.backend.reset_index()