def after_commit(cls, session): for obj in session._changes['add']: if isinstance(obj, SearchableMixin): add_to_index(obj.__tablename__, obj) for obj in session._changes['update']: if isinstance(obj, SearchableMixin): add_to_index(obj.__tablename__, obj) for obj in session._changes['delete']: if isinstance(obj, SearchableMixin): remove_from_index(obj.__tablename__, obj) session._changes = None
def change_group_description(form, group_id): GroupTable.query.filter_by(id=group_id).update( {"group_description": form.description.data}) db.session.commit() group_object = GroupTable.query.filter_by(id=group_id).first() add_to_index('group_table', group_object)
def reindex(cls): ''' add all objects to the index ''' for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): for obj in cls.query: # equals to cls.query.all() add_to_index(obj.__tablename__, obj)
def add_to_index(self): if self.published: add_to_index(self.__tablename__, self)
def reindex(cls): """adds database objects into elasticsearch""" for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): # reindex()类方法是一个简单的帮助方法,你可以使用它来刷新所有数据的索引。 # 有了这个方法,我可以调用Post.reindex()将数据库中的所有用户动态添加到搜索索引中 for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): for x in cls.query: add_to_index(cls.__tablename__, x)
def reindex(cls): for obj in cls.query: print("Add Post: <" + str(obj.id) + " " + obj.body + "> into " + cls.__tablename__) add_to_index(cls.__tablename__, obj)
def reindex(cls): ''' Helper method to refresh data from relational DB to search index. ''' for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindx(cls): # 这是一个辅助方法,用于一次性的加载数据库中的数据到ES for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): """用于初始化数据库已有数据""" for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): # 例如Post.query, 用for遍历这个可迭代对象,就可得到所有的Post对象 for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): """Re-index all objects in the table""" for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): #adds all posts in db to search index for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): """refresh search index with all data from db""" for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): # refreshes the Elasticsearch index with all data from relational side. for obj in cls.query: add_to_index(cls.__tablename__, obj)
def reindex(cls): # 帮助方法,刷新所有数据索引 for obj in cls.query: add_to_index(cls.__tablename__, obj)