Commit 0981258b5f24ef6dae860ef37b5aff755e4f1ed5
1 parent
7d24a4b7
Exists in
master
and in
39 other branches
Normalizing search queries #15
Showing
6 changed files
with
36 additions
and
13 deletions
Show diff stats
src/accounts/templates/search/indexes/accounts/user_text.txt
1 | {{ object.username }} | 1 | {{ object.username }} |
2 | {{ object.get_full_name }} | 2 | {{ object.get_full_name }} |
3 | -{{ object.email }} | 3 | +{{ object.get_full_name|slugify }} |
4 | {{ object.institution }} | 4 | {{ object.institution }} |
5 | +{{ object.institution|slugify }} | ||
5 | {{ object.role }} | 6 | {{ object.role }} |
6 | -{{ object.twitter }} | ||
7 | -{{ object.facebook }} | ||
8 | -{{ object.google_talk }} | ||
9 | -{{ object.webpage }} | 7 | +{{ object.role|slugify }} |
src/proxy/templates/search/indexes/proxy/revision_text.txt
1 | {{ object.repository_name }} | 1 | {{ object.repository_name }} |
2 | +{{ object.repository_name|slugify }} | ||
2 | {{ object.revision }} | 3 | {{ object.revision }} |
4 | +{{ object.revision|slugify }} | ||
3 | {% firstof object.get_author.get_full_name object.author %} | 5 | {% firstof object.get_author.get_full_name object.author %} |
6 | +{% firstof object.get_author.get_full_name|slugify object.author|slugify %} | ||
4 | {{ object.message }} | 7 | {{ object.message }} |
8 | +{{ object.message|slugify }} |
src/proxy/templates/search/indexes/proxy/ticket_text.txt
1 | {{ object.summary }} | 1 | {{ object.summary }} |
2 | +{{ object.summary|slugify }} | ||
2 | {{ object.description }} | 3 | {{ object.description }} |
4 | +{{ object.description|slugify }} | ||
3 | {{ object.milestone }} | 5 | {{ object.milestone }} |
4 | -{{ object.component }} | 6 | +{{ object.milestone|slugify }} |
7 | +{{ object.component|slugify }} | ||
5 | {{ object.version }} | 8 | {{ object.version }} |
6 | {{ object.severity }} | 9 | {{ object.severity }} |
10 | +{{ object.severity|slugify }} | ||
7 | {{ object.reporter }} | 11 | {{ object.reporter }} |
12 | +{{ object.reporter|slugify }} | ||
8 | {% firstof object.get_author.get_fullname or object.author %} | 13 | {% firstof object.get_author.get_fullname or object.author %} |
14 | +{% firstof object.get_author.get_fullname|slugify or object.author|slugify %} | ||
9 | {{ object.status }} | 15 | {{ object.status }} |
16 | +{{ object.status|slugify }} | ||
10 | {{ object.keywords }} | 17 | {{ object.keywords }} |
18 | +{{ object.keywords|slugify }} | ||
11 | {{ object.collaborators }} | 19 | {{ object.collaborators }} |
20 | +{{ object.collaborators|slugify }} |
src/proxy/templates/search/indexes/proxy/wiki_text.txt
1 | +{{ object.author }} | ||
2 | +{{ object.author|slugify }} | ||
1 | {{ object.name }} | 3 | {{ object.name }} |
2 | -{{ object.get_collaborators }} | ||
3 | -{{ object.text }} | 4 | +{{ object.name|slugify }} |
5 | +{{ object.collaborators }} | ||
6 | +{{ object.collaborators|slugify }} | ||
7 | +{{ object.wiki_text }} | ||
8 | +{{ object.wiki_text|slugify }} |
src/search/forms.py
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | 2 | ||
3 | +import unicodedata | ||
4 | + | ||
3 | from django import forms | 5 | from django import forms |
4 | from django.utils.translation import ugettext_lazy as _ | 6 | from django.utils.translation import ugettext_lazy as _ |
5 | from haystack.forms import SearchForm | 7 | from haystack.forms import SearchForm |
@@ -17,7 +19,10 @@ class ColabSearchForm(SearchForm): | @@ -17,7 +19,10 @@ class ColabSearchForm(SearchForm): | ||
17 | return self.no_query_found() | 19 | return self.no_query_found() |
18 | 20 | ||
19 | if self.cleaned_data.get('q'): | 21 | if self.cleaned_data.get('q'): |
20 | - sqs = self.searchqueryset.auto_query(self.cleaned_data['q']) | 22 | + q = unicodedata.normalize( |
23 | + 'NFKD', unicode(self.cleaned_data.get('q')) | ||
24 | + ).encode('ascii', 'ignore') | ||
25 | + sqs = self.searchqueryset.auto_query(q) | ||
21 | else: | 26 | else: |
22 | sqs = self.searchqueryset.all() | 27 | sqs = self.searchqueryset.all() |
23 | 28 | ||
@@ -35,8 +40,6 @@ class ColabSearchForm(SearchForm): | @@ -35,8 +40,6 @@ class ColabSearchForm(SearchForm): | ||
35 | # sqs = self.searchqueryset.models(Ticket) | 40 | # sqs = self.searchqueryset.models(Ticket) |
36 | # else: | 41 | # else: |
37 | # sqs = self.searchqueryset.all() | 42 | # sqs = self.searchqueryset.all() |
38 | - else: | ||
39 | - sqs = self.searchqueryset.models(User, Message) | ||
40 | 43 | ||
41 | 44 | ||
42 | if self.load_all: | 45 | if self.load_all: |
src/super_archives/templates/search/indexes/super_archives/message_text.txt
1 | {{ object.thread.mailinglist.name }} | 1 | {{ object.thread.mailinglist.name }} |
2 | +{{ object.thread.mailinglist.name|slugify }} | ||
2 | {{ object.thread.subject_token }} | 3 | {{ object.thread.subject_token }} |
4 | + | ||
3 | {{ object.body }} | 5 | {{ object.body }} |
6 | +{{ object.body|slugify }} | ||
4 | {{ object.subject_clean }} | 7 | {{ object.subject_clean }} |
5 | -{{ object.url }} | ||
6 | -{{ object.received_time }} | 8 | +{{ object.subject_clean|slugify }} |
9 | + | ||
10 | +{{ object.from_address.get_full_name }} |