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
评论列表
文章目录