##// END OF EJS Templates
#453 added ID field in whoosh SCHEMA that solves the issue of reindexing modified files
marcink -
r2388:a0ef98f2 beta
parent child Browse files
Show More
@@ -57,6 +57,7 b' ANALYZER = RegexTokenizer(expression=r"\\'
57
57
58 #INDEX SCHEMA DEFINITION
58 #INDEX SCHEMA DEFINITION
59 SCHEMA = Schema(
59 SCHEMA = Schema(
60 fileid=ID(unique=True),
60 owner=TEXT(),
61 owner=TEXT(),
61 repository=TEXT(stored=True),
62 repository=TEXT(stored=True),
62 path=TEXT(stored=True),
63 path=TEXT(stored=True),
@@ -146,10 +146,12 b' class WhooshIndexingDaemon(object):'
146 u_content = u''
146 u_content = u''
147 indexed += 1
147 indexed += 1
148
148
149 p = safe_unicode(path)
149 writer.add_document(
150 writer.add_document(
151 fileid=p,
150 owner=unicode(repo.contact),
152 owner=unicode(repo.contact),
151 repository=safe_unicode(repo_name),
153 repository=safe_unicode(repo_name),
152 path=safe_unicode(path),
154 path=p,
153 content=u_content,
155 content=u_content,
154 modtime=self.get_node_mtime(node),
156 modtime=self.get_node_mtime(node),
155 extension=node.extension
157 extension=node.extension
@@ -214,8 +216,11 b' class WhooshIndexingDaemon(object):'
214 if mtime > indexed_time:
216 if mtime > indexed_time:
215 # The file has changed, delete it and add it to the list of
217 # The file has changed, delete it and add it to the list of
216 # files to reindex
218 # files to reindex
217 log.debug('adding to reindex list %s' % indexed_path)
219 log.debug('adding to reindex list %s mtime: %s vs %s' % (
218 writer.delete_by_term('path', indexed_path)
220 indexed_path, mtime, indexed_time)
221 )
222 writer.delete_by_term('fileid', indexed_path)
223
219 to_index.add(indexed_path)
224 to_index.add(indexed_path)
220 except (ChangesetError, NodeDoesNotExistError):
225 except (ChangesetError, NodeDoesNotExistError):
221 # This file was deleted since it was indexed
226 # This file was deleted since it was indexed
@@ -230,6 +235,7 b' class WhooshIndexingDaemon(object):'
230 for path in self.get_paths(repo):
235 for path in self.get_paths(repo):
231 path = safe_unicode(path)
236 path = safe_unicode(path)
232 if path in to_index or path not in indexed_paths:
237 if path in to_index or path not in indexed_paths:
238
233 # This is either a file that's changed, or a new file
239 # This is either a file that's changed, or a new file
234 # that wasn't indexed before. So index it!
240 # that wasn't indexed before. So index it!
235 i, iwc = self.add_doc(writer, path, repo, repo_name)
241 i, iwc = self.add_doc(writer, path, repo, repo_name)
General Comments 0
You need to be logged in to leave comments. Login now