Navigation Menu

Skip to content

Commit

Permalink
bug 593260, Only use extended search if necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
davedash committed Sep 7, 2010
1 parent 77346db commit e9b40e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions apps/search/client.py
Expand Up @@ -367,6 +367,11 @@ def query(self, term, limit=10, offset=0, **kwargs):
"""
sc = self.sphinx
if 'match' in kwargs:
try:
sc.SetMatchMode(kwargs['match'])
except:
log.error('Invalid match mode: %s' % kwargs['match'])

# Setup some default parameters for the search.
fields = ("addon_id, app, category, %s" % self.weight_field)
Expand Down
6 changes: 4 additions & 2 deletions apps/search/views.py
Expand Up @@ -17,7 +17,7 @@
from versions.compare import dict_from_int, version_int
from search import forms
from search.client import (Client as SearchClient, SearchError,
CollectionsClient, PersonasClient)
CollectionsClient, PersonasClient, sphinx)
from search.forms import SearchForm, SecondarySearchForm

DEFAULT_NUM_RESULTS = 20
Expand Down Expand Up @@ -220,7 +220,9 @@ def ajax_search(request):
q = request.GET.get('q', '')
client = SearchClient()
try:
results = client.query('@name ' + q, limit=10)

results = client.query('@name ' + q, limit=10,
match=sphinx.SPH_MATCH_EXTENDED2)
return [dict(id=result.id, label=unicode(result.name),
icon=result.icon_url, value=unicode(result.name).lower())
for result in results]
Expand Down

0 comments on commit e9b40e1

Please sign in to comment.