fake_elasticsearch.py 文件源码

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

项目:elasticmock 作者: vrcmarcos 项目源码 文件源码
def suggest(self, body, index=None, params=None):
        if index is not None and index not in self.__documents_dict:
            raise NotFoundError(404, 'IndexMissingException[[{0}] missing]'.format(index))

        result_dict = {}
        for key, value in body.items():
            text = value.get('text')
            suggestion = int(text) + 1 if isinstance(text, int) else '{0}_suggestion'.format(text)
            result_dict[key] = [
                {
                    'text': text,
                    'length': 1,
                    'options': [
                        {
                            'text': suggestion,
                            'freq': 1,
                            'score': 1.0
                        }
                    ],
                    'offset': 0
                }
            ]
        return result_dict
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号