elastic2_doc_manager.py 文件源码

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

项目:elastic2-doc-manager 作者: mongodb-labs 项目源码 文件源码
def get_last_doc(self):
        """Get the most recently modified document from Elasticsearch.

        This method is used to help define a time window within which documents
        may be in conflict after a MongoDB rollback.
        """
        try:
            result = self.elastic.search(
                index=self.meta_index_name,
                body={
                    "query": {"match_all": {}},
                    "sort": [{"_ts": "desc"}],
                },
                size=1
            )["hits"]["hits"]
            for r in result:
                r['_source']['_id'] = r['_id']
                return r['_source']
        except es_exceptions.RequestError:
            # no documents so ES returns 400 because of undefined _ts mapping
            return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号