Commit 50c8a8b79b5f6358de72a9ec7479eee3e34a7cd7

Authored by Luan
2 parents cddbd38e d70cc0d4

Merge branch 'master' of github.com:TracyWebTech/colab

Showing 1 changed file with 14 additions and 12 deletions   Show diff stats
src/search/forms.py
@@ -91,18 +91,20 @@ class ColabSearchForm(SearchForm): @@ -91,18 +91,20 @@ class ColabSearchForm(SearchForm):
91 if self.cleaned_data['used_by']: 91 if self.cleaned_data['used_by']:
92 sqs = sqs.filter_or(used_by__in=self.cleaned_data['used_by'].split()) 92 sqs = sqs.filter_or(used_by__in=self.cleaned_data['used_by'].split())
93 93
94 - q = unicodedata.normalize(  
95 - 'NFKD', unicode(self.cleaned_data.get('q'))  
96 - ).encode('ascii', 'ignore')  
97 -  
98 - dismax_opts = {  
99 - 'q.alt': '*.*',  
100 - 'pf': 'title^2.1 author^1.9 description^1.7',  
101 - 'mm': '2<70%',  
102 - 'bf': 'recip(ms(NOW/DAY,modified),3.16e-11,1,1)^10',  
103 - }  
104 -  
105 - sqs = sqs.filter(content=AltParser('dismax', q, **dismax_opts)) 94 +
  95 + if self.cleaned_data['q']:
  96 + q = unicodedata.normalize(
  97 + 'NFKD', self.cleaned_data.get('q')
  98 + ).encode('ascii', 'ignore')
  99 +
  100 + dismax_opts = {
  101 + 'q.alt': '*.*',
  102 + 'pf': 'title^2.1 author^1.9 description^1.7',
  103 + 'mm': '2<70%',
  104 + 'bf': 'recip(ms(NOW/HOUR,modified),3.16e-11,1,1)^10',
  105 + }
  106 +
  107 + sqs = sqs.filter(content=AltParser('edismax', q, **dismax_opts))
106 108
107 if self.cleaned_data['type']: 109 if self.cleaned_data['type']:
108 sqs = sqs.filter(type=self.cleaned_data['type']) 110 sqs = sqs.filter(type=self.cleaned_data['type'])