solr 索引java_如何使用Java在Solr中获取索引大小

我需要使用Java在Apache

Solr中获取索引的总大小。以下代码获取文档总数,但是我正在寻找大小。并通过使用ReplicationHandler,我想我可以得到此链接上某人告诉的索引大小。http://lucene.472066.n3.nabble.com/cheking-

the-size-of-the- index-using-solrj-API-s-

td692686.html,但是我没有得到索引大小。

BufferedWriter out1 = null;

FileWriter fstream1 = new FileWriter("src/test/resources/solr-document-id-desc.txt");

out1 = new BufferedWriter(fstream1);

ApplicationContext context = null;

context = new ClassPathXmlApplicationContext("application-context.xml");

CommonsHttpSolrServer solrServer = (CommonsHttpSolrServer) context.getBean("solrServer");

SolrQuery solrQuery = new SolrQuery().setQuery("*:*");

QueryResponse rsp = solrServer.query(solrQuery);

//I am trying to use replicationhandler but I am not able to get the index size using statistics. Is there any way to get the index size..?

ReplicationHandler handler2 = new ReplicationHandler();

System.out.println( handler2.getDescription());

NamedList statistics = handler2.getStatistics();

System.out.println("Statistics "+ statistics);

System.out.println(rsp.getResults().getNumFound());

Iterator iter = rsp.getResults().iterator();

while (iter.hasNext()) {

SolrDocument resultDoc = iter.next();

System.out.println(resultDoc.getFieldNames());

String id = (String) resultDoc.getFieldValue("numFound");

String description = (String) resultDoc.getFieldValue("description");

System.out.println(id+"~~"+description);

out1.write(id+"~~"+description);

out1.newLine();

}

out1.close();

Any suggestions will be appreciated..

更新代码:

ReplicationHandler handler2 = new ReplicationHandler();

System.out.println( handler2.getDescription());

NamedList statistics = handler2.getStatistics();

System.out.println("Statistics "+ statistics.get("indexSize"));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值