如何使用Solrj获取Solr主从复制状态

huangapple go评论97阅读模式
英文:

How to get the Solr Master Slave replication status using Solrj

问题

我正在尝试使用SolrJ检索Solr主从复制状态。我还没有找到如何使用Core Admin调用获取此信息或将请求处理程序设置为复制处理程序。

或者我是否可以使用SolrJ调用此HTTP API调用:

http://host:port/solr/core_name/replication?command=indexversion

但是目前我不知道如何实现这一点。

寻找在这个方向上的指引。

英文:

I am trying to retrieve the Solr Master Slave replication status using SolrJ. I have not been able to find how to get this using the Core Admin calls or set the request handler to the Replication handler.

Or perhaps I could call this HTTP API call using SolrJ

http://host:port/solr/core_name/replication?command=indexversion

But how to that is something that escapes me currently.

Looking for pointers in this direction.

答案1

得分: 0

以下是翻译好的部分:

只是为了帮助某人,我获取所需数据的操作如下:

        SolrClient solrServer = new HttpSolrClient.Builder("http://localhost:8983/solr/" + coreName).build();
        SolrQuery query = new SolrQuery();
        query.setRequestHandler("/replication");
        query.set("command", "indexversion");
        query.set("wt", "json");
        query.set("indent", "true");

        // 发送 Solr 查询
        QueryResponse response = solrServer.query(query);

        // 从响应中获取 indexversion 值
        String indexVersion = 
        response.getResponse().get("indexversion").toString();
英文:

Just in case this helps someone, what I did to get the data I needed was

    SolrClient solrServer = new HttpSolrClient.Builder("http://localhost:8983/solr/" + coreName).build();
    SolrQuery query = new SolrQuery();
    query.setRequestHandler("/replication");
    query.set("command", "indexversion");
    query.set("wt", "json");
    query.set("indent", "true");

    //fire the solr query
    QueryResponse response = solrServer.query(query);

    //get the indexversion value from response
    String indexVersion = 
    response.getResponse().get("indexversion").toString();

huangapple
  • 本文由 发表于 2023年3月7日 19:45:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661576.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定