##// 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 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
58 passing repo locations to index, as well as Your config file that stores
59 whoosh index files locations. There is possible to pass `-f` to the options
57 Starting from version 1.1 whoosh index can be build using paster command.
58 You have to specify the config file that stores location of index, and
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 65 to enable full index rebuild. Without that indexing will run always in in
61 66 incremental mode.
62 67
63 ::
68 incremental mode::
64 69
65 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 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
76 index builds and keep Your index always up to date. An example entry might
77 look like this
83
84 In order to do periodical index builds and keep Your index always up to date.
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 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 93 of each file and add it to reindex if newer file is available. Also indexing
85 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 6 #to get the rhodecode import
7 7 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
8 8
9 from string import strip
10
9 11 from rhodecode.model import init_model
10 12 from rhodecode.model.scm import ScmModel
11 13 from rhodecode.config.environment import load_environment
@@ -71,6 +73,7 b' class MakeIndex(BasePasterCommand):'
71 73
72 74 index_location = config['index_dir']
73 75 repo_location = self.options.repo_location
76 repo_list = map(strip, self.options.repo_list.split(','))
74 77
75 78 #======================================================================
76 79 # WHOOSH DAEMON
@@ -80,7 +83,8 b' class MakeIndex(BasePasterCommand):'
80 83 try:
81 84 l = DaemonLock()
82 85 WhooshIndexingDaemon(index_location=index_location,
83 repo_location=repo_location)\
86 repo_location=repo_location,
87 repo_list=repo_list)\
84 88 .run(full_index=self.options.full_index)
85 89 l.release()
86 90 except LockHeld:
@@ -92,6 +96,12 b' class MakeIndex(BasePasterCommand):'
92 96 dest='repo_location',
93 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 105 self.parser.add_option('-f',
96 106 action='store_true',
97 107 dest='full_index',
@@ -70,7 +70,7 b' class WhooshIndexingDaemon(object):'
70 70 """
71 71
72 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 74 self.indexname = indexname
75 75
76 76 self.index_location = index_location
@@ -82,6 +82,16 b' class WhooshIndexingDaemon(object):'
82 82 raise Exception('You have to provide repositories location')
83 83
84 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 95 self.initial = False
86 96 if not os.path.isdir(self.index_location):
87 97 os.makedirs(self.index_location)
@@ -154,8 +164,8 b' class WhooshIndexingDaemon(object):'
154 164
155 165 idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
156 166 writer = idx.writer()
157 print self.repo_paths.values()
158 for cnt, repo in enumerate(self.repo_paths.values()):
167
168 for repo in self.repo_paths.values():
159 169 log.debug('building index @ %s' % repo.path)
160 170
161 171 for idx_path in self.get_paths(repo):
General Comments 0
You need to be logged in to leave comments. Login now