Merge branch 'kaedroho-search-query-normalisation-fix'

This commit is contained in:
Matt Westcott 2015-01-28 20:20:46 +00:00
commit 81327ec4e8
4 changed files with 30 additions and 6 deletions

View file

@ -26,7 +26,7 @@ Changelog
* Fix: get_sitemap_urls is now called on the specific page class so it can now be overridden (Jerel Unruh)
* Fix: (Firefox and IE) Fixed preview window hanging and not refocusing when "Preview" button is clicked again
* Fix: Storage backends that return raw ContentFile objects are now handled correctly when resizing images (@georgewhewell)
* Fix: Punctuation characters are no longer stripped when performing search queries
0.8.4 (04.12.2014)
~~~~~~~~~~~~~~~~~~

View file

@ -18,3 +18,4 @@ Bug fixes
* ``get_sitemap_urls`` is now called on the specific page class so it can now be overridden
* (Firefox and IE) Fixed preview window hanging and not refocusing when "Preview" button is clicked again
* Storage backends that return raw ContentFile objects are now handled correctly when resizing images
* Punctuation characters are no longer stripped when performing search queries

View file

@ -7,7 +7,6 @@ from django.db.models.sql.where import SubqueryConstraint, WhereNode
from django.core.exceptions import ImproperlyConfigured
from wagtail.wagtailsearch.index import class_is_indexed
from wagtail.wagtailsearch.utils import normalise_query_string
class FilterError(Exception):
@ -213,10 +212,6 @@ class BaseSearch(object):
if not class_is_indexed(model):
return []
# Normalise query string
if query_string is not None:
query_string = normalise_query_string(query_string)
# Check that theres still a query string after the clean up
if query_string == "":
return []

View file

@ -135,6 +135,34 @@ class TestElasticSearchBackend(BackendTests, TestCase):
# Even though they both start with the letter "H". This should not be considered a match
self.assertEqual(len(results), 0)
def test_search_with_hyphen(self):
"""
This tests that punctuation characters are treated the same
way in both indexing and querying.
See: https://github.com/torchbox/wagtail/issues/937
"""
# Reset the index
self.backend.reset_index()
self.backend.add_type(models.SearchTest)
self.backend.add_type(models.SearchTestChild)
# Add some test data
obj = models.SearchTest()
obj.title = "Hello-World"
obj.live = True
obj.save()
self.backend.add(obj)
# Refresh the index
self.backend.refresh_index()
# Test search for "Hello-World"
results = self.backend.search("Hello-World", models.SearchTest.objects.all())
# Should find the result
self.assertEqual(len(results), 1)
class TestElasticSearchQuery(TestCase):
def assertDictEqual(self, a, b):