engine.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
def _create_text_index(self, fields=None):
        """Create a text index for the database collection.

        Takes a list of fields and creates a text index based on the
        Engine's schema, if it has one. Otherwise, creates a text index
        for any field that contains string content.
        """
        collection = self._collection
        index_name = 'TextIndex'

        if fields:
            index = []
            for field in self.schema:
                if field.field_type in self.TEXT_INDEXES:
                    index.append((field.field_name, pymongo.TEXT))
            return collection.create_index(index, background=True,
                                           name=index_name)
        else:
            return collection.create_index([('$**', pymongo.TEXT)],
                                           name=index_name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号