Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow Boolean syntax, fix bug 627554

  • Loading branch information...
commit c73acfe785c160cdef34eb82c98df7bb054aab83 1 parent e5a081c
@davedash davedash authored
Showing with 9 additions and 0 deletions.
  1. +2 −0  apps/search/client.py
  2. +7 −0 apps/search/tests/test_client.py
View
2  apps/search/client.py
@@ -105,6 +105,7 @@ class Client(object):
def __init__(self):
self.sphinx = sphinx.SphinxClient()
+ self.sphinx.SetMatchMode(sphinx.SPH_MATCH_BOOLEAN)
if os.environ.get('DJANGO_ENVIRONMENT') == 'test':
self.sphinx.SetServer(settings.SPHINX_HOST,
@@ -176,6 +177,7 @@ def add_filter(self, field, values, meta=False):
def query(self, term, limit=20, offset=0, **kwargs):
"""Submits formatted query, retrieves ids, returns Opinions."""
sc = self.sphinx
+
term = sanitize_query(term)
# Extract and apply various filters.
View
7 apps/search/tests/test_client.py
@@ -99,6 +99,13 @@ def test_url_search(self):
start = datetime.datetime(2010, 5, 27)
eq_(num_results('url:*', date_start=start), 7)
+ def test_or_query(self):
+ """Sphinx supports or queries, e.g.: a | b."""
+ start = datetime.datetime(2010, 5, 27)
+ eq_(num_results('1st', date_start=start), 1)
+ eq_(num_results('2nd', date_start=start), 1)
+ eq_(num_results('1st | 2nd', date_start=start), 2)
+
def test_date_filter_timezone():
"""Ensure date filters are applied in app time (= PST), not UTC."""
Please sign in to comment.
Something went wrong with that request. Please try again.