英文:
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();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论