Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Try to keep 'do not reindex if not necessary' optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
gbastien committed Nov 15, 2012
1 parent f5a6ae6 commit 4aac7a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Products/ZCTextIndex/ZCTextIndex.py
Expand Up @@ -176,6 +176,7 @@ def index_object(self, documentId, obj, threshold=None):
try: fields = self._indexed_attrs
except: fields = [ self._fieldname ]

res = 0
all_texts = []
for attr in fields:
text = getattr(obj, attr, None)
Expand All @@ -194,7 +195,9 @@ def index_object(self, documentId, obj, threshold=None):
# Check that we're sending only strings
all_texts = filter(lambda text: isinstance(text, basestring), \
all_texts)
return self.index.index_doc(documentId, all_texts)
if all_texts or self.index.length():
return self.index.index_doc(documentId, all_texts)
return res

def unindex_object(self, docid):
if self.index.has_doc(docid):
Expand Down

0 comments on commit 4aac7a2

Please sign in to comment.