##// END OF EJS Templates
search: update whoosh fallback schema to sort on date too
dan -
r72:330a8ca8 default
parent child Browse files
Show More
@@ -1,75 +1,75 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2012-2016 RhodeCode GmbH
3 # Copyright (C) 2012-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 """
21 """
22 Whoosh fallback schema for RhodeCode in case rhodecode_tools defined one is
22 Whoosh fallback schema for RhodeCode in case rhodecode_tools defined one is
23 not available
23 not available
24 """
24 """
25
25
26 from __future__ import absolute_import
26 from __future__ import absolute_import
27
27
28 from whoosh.analysis import RegexTokenizer, LowercaseFilter
28 from whoosh.analysis import RegexTokenizer, LowercaseFilter
29 from whoosh.formats import Characters
29 from whoosh.formats import Characters
30 from whoosh.fields import (
30 from whoosh.fields import (
31 TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME)
31 TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME)
32
32
33 # CUSTOM ANALYZER wordsplit + lowercase filter for case insensitive search
33 # CUSTOM ANALYZER wordsplit + lowercase filter for case insensitive search
34 ANALYZER = RegexTokenizer(expression=r"\w+") | LowercaseFilter()
34 ANALYZER = RegexTokenizer(expression=r"\w+") | LowercaseFilter()
35
35
36 # FILE INDEX SCHEMA DEFINITION
36 # FILE INDEX SCHEMA DEFINITION
37 FILE_INDEX_NAME = 'FILE_INDEX'
37 FILE_INDEX_NAME = 'FILE_INDEX'
38 FILE_SCHEMA = Schema(
38 FILE_SCHEMA = Schema(
39 fileid=ID(unique=True), # Path
39 fileid=ID(unique=True), # Path
40 repository=ID(stored=True),
40 repository=ID(stored=True),
41 repository_id=NUMERIC(unique=True, stored=True), # Numeric id of repo
41 repository_id=NUMERIC(unique=True, stored=True), # Numeric id of repo
42 repo_name=TEXT(stored=True),
42 repo_name=TEXT(stored=True),
43 owner=TEXT(),
43 owner=TEXT(),
44 path=TEXT(stored=True),
44 path=TEXT(stored=True),
45 content=FieldType(format=Characters(), analyzer=ANALYZER,
45 content=FieldType(format=Characters(), analyzer=ANALYZER,
46 scorable=True, stored=True),
46 scorable=True, stored=True),
47 modtime=STORED(),
47 modtime=STORED(),
48 md5=STORED(),
48 md5=STORED(),
49 extension=ID(stored=True),
49 extension=ID(stored=True),
50 commit_id=TEXT(stored=True),
50 commit_id=TEXT(stored=True),
51
51
52 size=NUMERIC(stored=True),
52 size=NUMERIC(stored=True),
53 mimetype=TEXT(stored=True),
53 mimetype=TEXT(stored=True),
54 lines=NUMERIC(stored=True),
54 lines=NUMERIC(stored=True),
55 )
55 )
56
56
57
57
58 # COMMIT INDEX SCHEMA
58 # COMMIT INDEX SCHEMA
59 COMMIT_INDEX_NAME = 'COMMIT_INDEX'
59 COMMIT_INDEX_NAME = 'COMMIT_INDEX'
60 COMMIT_SCHEMA = Schema(
60 COMMIT_SCHEMA = Schema(
61 commit_id=ID(unique=True, stored=True),
61 commit_id=ID(unique=True, stored=True),
62 repository=ID(unique=True, stored=True),
62 repository=ID(unique=True, stored=True),
63 repository_id=NUMERIC(unique=True, stored=True),
63 repository_id=NUMERIC(unique=True, stored=True),
64 commit_idx=NUMERIC(stored=True, sortable=True),
64 commit_idx=NUMERIC(stored=True, sortable=True),
65 commit_idx_sort=ID(),
65 commit_idx_sort=ID(),
66 date=NUMERIC(stored=True),
66 date=NUMERIC(stored=True, sortable=True),
67 owner=TEXT(stored=True),
67 owner=TEXT(stored=True),
68 author=TEXT(stored=True),
68 author=TEXT(stored=True),
69 message=FieldType(format=Characters(), analyzer=ANALYZER,
69 message=FieldType(format=Characters(), analyzer=ANALYZER,
70 scorable=True, stored=True),
70 scorable=True, stored=True),
71 parents=TEXT(stored=True),
71 parents=TEXT(stored=True),
72 added=TEXT(stored=True), # space separated names of added files
72 added=TEXT(stored=True), # space separated names of added files
73 removed=TEXT(stored=True), # space separated names of removed files
73 removed=TEXT(stored=True), # space separated names of removed files
74 changed=TEXT(stored=True), # space separated names of changed files
74 changed=TEXT(stored=True), # space separated names of changed files
75 )
75 )
General Comments 0
You need to be logged in to leave comments. Login now