annotate rhodecode/controllers/search.py @ 4151:8b8f4a93c364 rhodecode-2.2.5-gpl

old style: show compare "Compare Revisions" inline ... and do the same with all other buttons
author Mads Kiilerich <madski@unity3d.com>
date Wed, 02 Jul 2014 19:03:24 -0400
parents ffd45b185016
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
1 # -*- coding: utf-8 -*-
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
2 # This program is free software: you can redistribute it and/or modify
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
3 # it under the terms of the GNU General Public License as published by
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
5 # (at your option) any later version.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
6 #
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # GNU General Public License for more details.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
11 #
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
14 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
15 rhodecode.controllers.search
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
18 Search controller for RhodeCode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
20 :created_on: Aug 7, 2010
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
24 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
25
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
26 import logging
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
27 import traceback
2913
bfffaa9aff58 #589 search urlgenerator didn't properly escape special chars on url
Marcin Kuzminski <marcin@python-works.com>
parents: 2845
diff changeset
28 import urllib
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
29 from pylons.i18n.translation import _
1995
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
30 from pylons import request, config, tmpl_context as c
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
31
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
32 from whoosh.index import open_dir, EmptyIndexError
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
33 from whoosh.qparser import QueryParser, QueryParserError
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
34 from whoosh.query import Phrase, Wildcard, Term, Prefix
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
35 from webhelpers.util import update_params
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
36
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 525
diff changeset
37 from rhodecode.lib.auth import LoginRequired
3289
666fc6ac9ce5 search: repo search is a repo thing - show it that way in ui and url
Mads Kiilerich <madski@unity3d.com>
parents: 2913
diff changeset
38 from rhodecode.lib.base import BaseRepoController, render
2646
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
39 from rhodecode.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
40 IDX_NAME, WhooshResultWrapper
2319
4c239e0dcbb7 fixes issue #454 Search results under Windows include preceeding backslash
Marcin Kuzminski <marcin@python-works.com>
parents: 1995
diff changeset
41 from rhodecode.model.repo import RepoModel
2845
6b176c679896 failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents: 2842
diff changeset
42 from rhodecode.lib.utils2 import safe_str, safe_int
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
43 from rhodecode.lib.helpers import Page
2913
bfffaa9aff58 #589 search urlgenerator didn't properly escape special chars on url
Marcin Kuzminski <marcin@python-works.com>
parents: 2845
diff changeset
44
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 log = logging.getLogger(__name__)
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
47
3289
666fc6ac9ce5 search: repo search is a repo thing - show it that way in ui and url
Mads Kiilerich <madski@unity3d.com>
parents: 2913
diff changeset
48 class SearchController(BaseRepoController):
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 def __before__(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 556
diff changeset
51 super(SearchController, self).__before__()
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
53 @LoginRequired()
3289
666fc6ac9ce5 search: repo search is a repo thing - show it that way in ui and url
Mads Kiilerich <madski@unity3d.com>
parents: 2913
diff changeset
54 def index(self, repo_name=None):
666fc6ac9ce5 search: repo search is a repo thing - show it that way in ui and url
Mads Kiilerich <madski@unity3d.com>
parents: 2913
diff changeset
55 c.repo_name = repo_name
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 c.formated_results = []
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 c.runtime = ''
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 c.cur_query = request.GET.get('q', None)
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
59 c.cur_type = request.GET.get('type', 'content')
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
60 c.cur_search = search_type = {'content': 'content',
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
61 'commit': 'message',
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
62 'path': 'path',
2646
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
63 'repository': 'repository'
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
64 }.get(c.cur_type, 'content')
556
65b2f150beb7 Added searching for file names within the repository in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
65
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
66 index_name = {
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
67 'content': IDX_NAME,
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
68 'commit': CHGSET_IDX_NAME,
2646
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
69 'path': IDX_NAME
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
70 }.get(c.cur_type, IDX_NAME)
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
71
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
72 schema_defn = {
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
73 'content': SCHEMA,
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
74 'commit': CHGSETS_SCHEMA,
2646
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
75 'path': SCHEMA
3013b753cbed code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2640
diff changeset
76 }.get(c.cur_type, SCHEMA)
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
77
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
78 log.debug('IDX: %s' % index_name)
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
79 log.debug('SCHEMA: %s' % schema_defn)
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
80
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 if c.cur_query:
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 cur_query = c.cur_query.lower()
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
83 log.debug(cur_query)
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 556
diff changeset
84
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 if c.cur_query:
3748
9d743ca9cede usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents: 3289
diff changeset
86 p = safe_int(request.GET.get('page', 1), 1)
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
87 highlight_items = set()
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 try:
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
89 idx = open_dir(config['app_conf']['index_dir'],
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
90 indexname=index_name)
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 searcher = idx.searcher()
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
92
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
93 qp = QueryParser(search_type, schema=schema_defn)
525
87d80c84df09 added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents: 478
diff changeset
94 if c.repo_name:
87d80c84df09 added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents: 478
diff changeset
95 cur_query = u'repository:%s %s' % (c.repo_name, cur_query)
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 try:
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 query = qp.parse(unicode(cur_query))
1995
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
98 # extract words for highlight
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 if isinstance(query, Phrase):
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
100 highlight_items.update(query.words)
1303
9773b46e239f whoosh errors don't crash entire app now, just display an error and log exception instead
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
101 elif isinstance(query, Prefix):
9773b46e239f whoosh errors don't crash entire app now, just display an error and log exception instead
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
102 highlight_items.add(query.text)
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103 else:
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 for i in query.all_terms():
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
105 if i[0] in ['content', 'message']:
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
106 highlight_items.add(i[1])
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
108 matcher = query.matcher(searcher)
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 556
diff changeset
109
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
110 log.debug('query: %s' % query)
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2319
diff changeset
111 log.debug('hl terms: %s' % highlight_items)
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
112 results = searcher.search(query)
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
113 res_ln = len(results)
1995
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
114 c.runtime = '%s results (%.3f seconds)' % (
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
115 res_ln, results.runtime
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
116 )
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 556
diff changeset
117
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
118 def url_generator(**kw):
2913
bfffaa9aff58 #589 search urlgenerator didn't properly escape special chars on url
Marcin Kuzminski <marcin@python-works.com>
parents: 2845
diff changeset
119 q = urllib.quote(safe_str(c.cur_query))
556
65b2f150beb7 Added searching for file names within the repository in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
120 return update_params("?q=%s&type=%s" \
2913
bfffaa9aff58 #589 search urlgenerator didn't properly escape special chars on url
Marcin Kuzminski <marcin@python-works.com>
parents: 2845
diff changeset
121 % (q, safe_str(c.cur_type)), **kw)
2319
4c239e0dcbb7 fixes issue #454 Search results under Windows include preceeding backslash
Marcin Kuzminski <marcin@python-works.com>
parents: 1995
diff changeset
122 repo_location = RepoModel().repos_path
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
123 c.formated_results = Page(
2319
4c239e0dcbb7 fixes issue #454 Search results under Windows include preceeding backslash
Marcin Kuzminski <marcin@python-works.com>
parents: 1995
diff changeset
124 WhooshResultWrapper(search_type, searcher, matcher,
4c239e0dcbb7 fixes issue #454 Search results under Windows include preceeding backslash
Marcin Kuzminski <marcin@python-works.com>
parents: 1995
diff changeset
125 highlight_items, repo_location),
1995
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
126 page=p,
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
127 item_count=res_ln,
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
128 items_per_page=10,
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
129 url=url_generator
b6c902d88472 bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
130 )
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 556
diff changeset
131
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132 except QueryParserError:
410
9a7ae16ff53e fixes translations, style updates.
Marcin Kuzminski <marcin@python-works.com>
parents: 406
diff changeset
133 c.runtime = _('Invalid search query. Try quoting it.')
478
7010af6efde5 Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents: 410
diff changeset
134 searcher.close()
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 except (EmptyIndexError, IOError):
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 log.error(traceback.format_exc())
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 log.error('Empty Index data')
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
138 c.runtime = _('There is no index to search in. '
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
139 'Please run whoosh indexer')
1303
9773b46e239f whoosh errors don't crash entire app now, just display an error and log exception instead
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
140 except (Exception):
9773b46e239f whoosh errors don't crash entire app now, just display an error and log exception instead
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
141 log.error(traceback.format_exc())
9773b46e239f whoosh errors don't crash entire app now, just display an error and log exception instead
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
142 c.runtime = _('An error occurred during this search operation')
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 556
diff changeset
143
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
144 # Return a rendered template
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 return render('/search/search.html')