##// END OF EJS Templates
fixes #90 + docs update
marcink -
r894:1fed3c91 beta
parent child Browse files
Show More
@@ -54,33 +54,42 b' You are ready to use rhodecode, to run i'
54 Setting up Whoosh full text search
54 Setting up Whoosh full text search
55 ----------------------------------
55 ----------------------------------
56
56
57 Index for whoosh can be build starting from version 1.1 using paster command
57 Starting from version 1.1 whoosh index can be build using paster command.
58 passing repo locations to index, as well as Your config file that stores
58 You have to specify the config file that stores location of index, and
59 whoosh index files locations. There is possible to pass `-f` to the options
59 location of repositories (`--repo-location`). Starting from version 1.2 it is
60 also possible to specify a comma separated list of repositories (`--index-only`)
61 to build index only on chooses repositories skipping any other found in repos
62 location
63
64 There is possible also to pass `-f` to the options
60 to enable full index rebuild. Without that indexing will run always in in
65 to enable full index rebuild. Without that indexing will run always in in
61 incremental mode.
66 incremental mode.
62
67
63 ::
68 incremental mode::
64
69
65 paster make-index production.ini --repo-location=<location for repos>
70 paster make-index production.ini --repo-location=<location for repos>
66
71
67 for full index rebuild You can use
72
68
73
69 ::
74 for full index rebuild You can use::
70
75
71 paster make-index production.ini -f --repo-location=<location for repos>
76 paster make-index production.ini -f --repo-location=<location for repos>
72
77
73 - For full text search You can either put crontab entry for
78
79 building index just for chosen repositories is possible with such command::
80
81 paster make-index production.ini --repo-location=<location for repos> --index-only=vcs,rhodecode
74
82
75 This command can be run even from crontab in order to do periodical
83
76 index builds and keep Your index always up to date. An example entry might
84 In order to do periodical index builds and keep Your index always up to date.
77 look like this
85 It's recommended to do a crontab entry for incremental indexing.
86 An example entry might look like this
78
87
79 ::
88 ::
80
89
81 /path/to/python/bin/paster /path/to/rhodecode/production.ini --repo-location=<location for repos>
90 /path/to/python/bin/paster /path/to/rhodecode/production.ini --repo-location=<location for repos>
82
91
83 When using incremental(default) mode whoosh will check last modification date
92 When using incremental (default) mode whoosh will check last modification date
84 of each file and add it to reindex if newer file is available. Also indexing
93 of each file and add it to reindex if newer file is available. Also indexing
85 daemon checks for removed files and removes them from index.
94 daemon checks for removed files and removes them from index.
86
95
@@ -6,6 +6,8 b' from os.path import dirname as dn, join '
6 #to get the rhodecode import
6 #to get the rhodecode import
7 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
7 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
8
8
9 from string import strip
10
9 from rhodecode.model import init_model
11 from rhodecode.model import init_model
10 from rhodecode.model.scm import ScmModel
12 from rhodecode.model.scm import ScmModel
11 from rhodecode.config.environment import load_environment
13 from rhodecode.config.environment import load_environment
@@ -71,6 +73,7 b' class MakeIndex(BasePasterCommand):'
71
73
72 index_location = config['index_dir']
74 index_location = config['index_dir']
73 repo_location = self.options.repo_location
75 repo_location = self.options.repo_location
76 repo_list = map(strip, self.options.repo_list.split(','))
74
77
75 #======================================================================
78 #======================================================================
76 # WHOOSH DAEMON
79 # WHOOSH DAEMON
@@ -80,7 +83,8 b' class MakeIndex(BasePasterCommand):'
80 try:
83 try:
81 l = DaemonLock()
84 l = DaemonLock()
82 WhooshIndexingDaemon(index_location=index_location,
85 WhooshIndexingDaemon(index_location=index_location,
83 repo_location=repo_location)\
86 repo_location=repo_location,
87 repo_list=repo_list)\
84 .run(full_index=self.options.full_index)
88 .run(full_index=self.options.full_index)
85 l.release()
89 l.release()
86 except LockHeld:
90 except LockHeld:
@@ -92,6 +96,12 b' class MakeIndex(BasePasterCommand):'
92 dest='repo_location',
96 dest='repo_location',
93 help="Specifies repositories location to index REQUIRED",
97 help="Specifies repositories location to index REQUIRED",
94 )
98 )
99 self.parser.add_option('--index-only',
100 action='store',
101 dest='repo_list',
102 help="Specifies a comma separated list of repositores "
103 "to build index on OPTIONAL",
104 )
95 self.parser.add_option('-f',
105 self.parser.add_option('-f',
96 action='store_true',
106 action='store_true',
97 dest='full_index',
107 dest='full_index',
@@ -70,7 +70,7 b' class WhooshIndexingDaemon(object):'
70 """
70 """
71
71
72 def __init__(self, indexname='HG_INDEX', index_location=None,
72 def __init__(self, indexname='HG_INDEX', index_location=None,
73 repo_location=None, sa=None):
73 repo_location=None, sa=None, repo_list=None):
74 self.indexname = indexname
74 self.indexname = indexname
75
75
76 self.index_location = index_location
76 self.index_location = index_location
@@ -82,6 +82,16 b' class WhooshIndexingDaemon(object):'
82 raise Exception('You have to provide repositories location')
82 raise Exception('You have to provide repositories location')
83
83
84 self.repo_paths = ScmModel(sa).repo_scan(self.repo_location, None)
84 self.repo_paths = ScmModel(sa).repo_scan(self.repo_location, None)
85
86 if repo_list:
87 filtered_repo_paths = {}
88 for repo_name, repo in self.repo_paths.items():
89 if repo_name in repo_list:
90 filtered_repo_paths[repo.name] = repo
91
92 self.repo_paths = filtered_repo_paths
93
94
85 self.initial = False
95 self.initial = False
86 if not os.path.isdir(self.index_location):
96 if not os.path.isdir(self.index_location):
87 os.makedirs(self.index_location)
97 os.makedirs(self.index_location)
@@ -154,8 +164,8 b' class WhooshIndexingDaemon(object):'
154
164
155 idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
165 idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
156 writer = idx.writer()
166 writer = idx.writer()
157 print self.repo_paths.values()
167
158 for cnt, repo in enumerate(self.repo_paths.values()):
168 for repo in self.repo_paths.values():
159 log.debug('building index @ %s' % repo.path)
169 log.debug('building index @ %s' % repo.path)
160
170
161 for idx_path in self.get_paths(repo):
171 for idx_path in self.get_paths(repo):
General Comments 0
You need to be logged in to leave comments. Login now