Mercurial > kallithea
annotate rhodecode/controllers/search.py @ 3026:ff9e0cbfcd7f beta
fixed tests for databases that have FKs. Thank you sqlite...
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 24 Nov 2012 02:12:48 +0100 |
parents | bfffaa9aff58 |
children | a5f0bc867edc 666fc6ac9ce5 |
rev | line source |
---|---|
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
2 """ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
3 rhodecode.controllers.search |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
5 |
2646 | 6 Search controller for RhodeCode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
7 |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
8 :created_on: Aug 7, 2010 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1303
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # 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
|
14 # 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
|
15 # 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
|
16 # (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
|
17 # |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # 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
|
19 # 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
|
20 # 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
|
21 # 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
|
22 # |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # 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
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
25 import logging |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
26 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
|
27 import urllib |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
28 from pylons.i18n.translation import _ |
1995
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
29 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
|
30 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
31 from rhodecode.lib.auth import LoginRequired |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
32 from rhodecode.lib.base import BaseController, render |
2646 | 33 from rhodecode.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \ |
34 IDX_NAME, WhooshResultWrapper | |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
35 |
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
|
36 from webhelpers.paginate import Page |
7010af6efde5
Reimplemented searching for speed on large files and added paging for search results
Marcin Kuzminski <marcin@python-works.com>
parents:
410
diff
changeset
|
37 from webhelpers.util import update_params |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
38 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 from whoosh.index import open_dir, EmptyIndexError |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 from whoosh.qparser import QueryParser, QueryParserError |
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
|
41 from whoosh.query import Phrase, Wildcard, Term, Prefix |
2319
4c239e0dcbb7
fixes issue #454 Search results under Windows include preceeding backslash
Marcin Kuzminski <marcin@python-works.com>
parents:
1995
diff
changeset
|
42 from rhodecode.model.repo import RepoModel |
2845
6b176c679896
failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents:
2842
diff
changeset
|
43 from rhodecode.lib.utils2 import safe_str, safe_int |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
2913
bfffaa9aff58
#589 search urlgenerator didn't properly escape special chars on url
Marcin Kuzminski <marcin@python-works.com>
parents:
2845
diff
changeset
|
45 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 log = logging.getLogger(__name__) |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 |
1212 | 48 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 class SearchController(BaseController): |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 @LoginRequired() |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 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
|
53 super(SearchController, self).__before__() |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
478
diff
changeset
|
55 def index(self, search_repo=None): |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
478
diff
changeset
|
56 c.repo_name = search_repo |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 c.formated_results = [] |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 c.runtime = '' |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 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
|
60 c.cur_type = request.GET.get('type', 'content') |
1212 | 61 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
|
62 'commit': 'message', |
1212 | 63 'path': 'path', |
2646 | 64 'repository': 'repository' |
65 }.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
|
66 |
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
|
67 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
|
68 '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
|
69 'commit': CHGSET_IDX_NAME, |
2646 | 70 'path': IDX_NAME |
71 }.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
|
72 |
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 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
|
74 '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
|
75 'commit': CHGSETS_SCHEMA, |
2646 | 76 'path': SCHEMA |
77 }.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
|
78 |
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('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
|
80 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
|
81 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 if c.cur_query: |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 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
|
84 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
|
85 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 if c.cur_query: |
2845
6b176c679896
failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents:
2842
diff
changeset
|
87 p = safe_int(request.params.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
|
88 highlight_items = set() |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 try: |
1212 | 90 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
|
91 indexname=index_name) |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
92 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
|
93 |
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
|
94 qp = QueryParser(search_type, schema=schema_defn) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
478
diff
changeset
|
95 if c.repo_name: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
478
diff
changeset
|
96 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
|
97 try: |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 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
|
99 # extract words for highlight |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 highlight_items.add(query.text) |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 else: |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 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
|
106 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
|
107 highlight_items.add(i[1]) |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
108 |
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
|
109 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
|
110 |
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
|
111 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
|
112 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
|
113 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
|
114 res_ln = len(results) |
1995
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
115 c.runtime = '%s results (%.3f seconds)' % ( |
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
116 res_ln, results.runtime |
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
117 ) |
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
|
118 |
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
|
119 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
|
120 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
|
121 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
|
122 % (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
|
123 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
|
124 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
|
125 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
|
126 highlight_items, repo_location), |
1995
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
127 page=p, |
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
128 item_count=res_ln, |
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
129 items_per_page=10, |
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
130 url=url_generator |
b6c902d88472
bumbed whoosh to 2.3.X series
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
131 ) |
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
|
132 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 except QueryParserError: |
410
9a7ae16ff53e
fixes translations, style updates.
Marcin Kuzminski <marcin@python-works.com>
parents:
406
diff
changeset
|
134 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
|
135 searcher.close() |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 except (EmptyIndexError, IOError): |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 log.error(traceback.format_exc()) |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 log.error('Empty Index data') |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
139 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
|
140 '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
|
141 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
|
142 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
|
143 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
|
144 |
406
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 # Return a rendered template |
b153a51b1d3b
Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 return render('/search/search.html') |