2014-07-06 37 views
0

我正在開發一個自定義Solr搜索組件,該組件考慮了集合中文檔的數量。目前,我的Solr配置文件中文檔的數量已被硬編碼,這很糟糕,因爲文檔的數量是動態的。是否有可能從響應構建器獲取文檔的數量(在整個集合中,而不是在單個核心中)?到目前爲止,我已經找到了獲取雲描述符(rb.req.getCore().getCoreDescriptor().getCloudDescriptor())的方法,但與我的期望相反,我沒有在其中看到getNumDocs()方法。獲取Solr雲集閤中文檔的數量

+1

「*:*'查詢返回什麼? –

回答

1

我使用以下代碼在我的SOLR雲集中獲取NumberOfDocuments。

HttpSolrServer httpSolrServer = new HttpSolrServer("http://localhost:8983/solr/collectionname/"); 
QueryResponse response = httpSolrServer.query(new SolrQuery(), METHOD.POST);  
SolrDocumentList solrDocumentList = queryResponse.getResults(); 
solrDocumentList.getNumFound(); 
solrDocumentList.getStart(); 

希望能幫到你!

相關問題