def update(self, index, iterable, commit=True): if not self.setup_complete: self.setup() self.index = self.index.refresh() writer = self.index.writer() for obj in iterable: doc = {} doc['id'] = force_unicode(self.get_identifier(obj)) doc['django_ct'] = force_unicode("%s.%s" % (obj._meta.app_label, obj._meta.module_name)) doc['django_id'] = force_unicode(obj.pk) other_data = index.prepare(obj) # Really make sure it's unicode, because Whoosh won't have it any # other way. for key in other_data: other_data[key] = self._from_python(other_data[key]) doc.update(other_data) writer.update_document(**doc) # For now, commit no matter what, as we run into locking issues otherwise. writer.commit() # If spelling support is desired, add to the dictionary. if getattr(settings, 'HAYSTACK_INCLUDE_SPELLING', False) is True: sp = SpellChecker(self.storage) sp.add_field(self.index, self.content_field_name)
def update(self, index, iterable, commit=True): if not self.setup_complete: self.setup() self.index = self.index.refresh() writer = self.index.writer() for obj in iterable: doc = index.prepare(obj) # Really make sure it's unicode, because Whoosh won't have it any # other way. for key in doc: doc[key] = self._from_python(doc[key]) writer.update_document(**doc) if len(iterable) > 0: # For now, commit no matter what, as we run into locking issues otherwise. writer.commit() # If spelling support is desired, add to the dictionary. if getattr(settings, "HAYSTACK_INCLUDE_SPELLING", False) is True: sp = SpellChecker(self.storage) sp.add_field(self.index, self.content_field_name)
def update(self, index, iterable, commit=True): if not self.setup_complete: self.setup() writer = self.index.writer() for obj in iterable: doc = {} doc['id'] = force_unicode(self.get_identifier(obj)) doc['django_ct_s'] = force_unicode("%s.%s" % (obj._meta.app_label, obj._meta.module_name)) doc['django_id_s'] = force_unicode(obj.pk) other_data = index.prepare(obj) # Really make sure it's unicode, because Whoosh won't have it any # other way. for key in other_data: other_data[key] = self._from_python(other_data[key]) doc.update(other_data) writer.update_document(**doc) # For now, commit no matter what, as we run into locking issues otherwise. writer.commit()