如何使用Java获取Solr中的索引大小
发布时间:2020-12-15 04:56:04 所属栏目:Java 来源:网络整理
导读:我需要使用 Java获取Apache Solr中索引的总大小.以下代码获取文档总数,但我正在寻找大小.并且通过使用ReplicationHandler,我认为我可以获得此链接上有人告诉的索引大小. http://lucene.472066.n3.nabble.com/cheking-the-size-of-the-index-using-solrj-API-
我需要使用
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<SolrDocument> 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")); 解决方法
indexsize可用于
ReplicationHandler中的统计信息
org.apache.solr.handler.ReplicationHandler 码 public NamedList getStatistics() { NamedList list = super.getStatistics(); if (core != null) { list.add("indexSize",NumberUtils.readableSize(getIndexSize())); } } 您可以使用URL http:// localhost:8983 / solr / replication?command = details,它返回索引大小. <lst name="details"> <str name="indexSize">26.13 KB</str> ..... </lst> 不确定它是否适用于ReplicationHandler的实例化,因为它需要核心和索引的引用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- java – 使用Apache Mina作为模拟/内存SFTP服务器进行单元测
- Spring向页面传值和接受页面传过来的参数详解
- playframework – 引起:javax.persistence.EntityNotFound
- Java concurrency线程池之Callable和Future_动力节点Java学
- Java 类加载机制详解
- 如何通过java:com / env-scheme在glassfish中查看自定义资
- PDF到文本工具或Java库?
- Common Lisp是否有类似java的Set Interface /实现类?
- java的Comparable接口详解
- 在java中使用接口.新问题