index_document.py 文件源码

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

项目:data-store 作者: HumanCellAtlas 项目源码 文件源码
def get_indexed_versions(self) -> typing.MutableMapping[str, str]:
        """
        Returns a dictionary mapping the name of each index containing this document to the
        version of this document in that index. Note that `version` denotes document version, not
        bundle version.
        """
        page_size = 64
        es_client = ElasticsearchClient.get(self.logger)
        alias_name = Config.get_es_alias_name(ESIndexType.docs, self.replica)
        response = es_client.search(index=alias_name, body={
            '_source': False,
            'stored_fields': [],
            'version': True,
            'from': 0,
            'size': page_size,
            'query': {
                'terms': {
                    '_id': [str(self.fqid)]
                }
            }
        })
        hits = response['hits']
        assert hits['total'] <= page_size, 'Document is in too many indices'
        indices = {hit['_index']: hit['_version'] for hit in hits['hits']}
        return indices
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号