def update_index(sender, instance, created, **kwargs):
    if isinstance(instance, Object) and instance.is_searchable():
        search_item = instance.get_search_item()
        ix = index.open_dir(settings.WHOOSH_INDEX)
        try:
            writer = ix.writer()
            try:
                if created:
                    writer.add_document(id=search_item['id'],
                                        name=search_item['name'],
                                        type=search_item['type'],
                                        content=search_item['content'],
                                        url=unicode(search_item['url']))
                    writer.commit()
                else:
                    writer.update_document(id=search_item['id'],
                                           name=search_item['name'],
                                           type=search_item['type'],
                                           content=search_item['content'],
                                           url=search_item['url'])
                    writer.commit()
            except:
                writer.cancel()
        except:
            pass
Add Object to search index
dataset/ETHPy150Open treeio/treeio/treeio/core/search/models.py/update_index