将 SolrdocumentList 更改转换为 List
Convert SolrdocumentList change to List
例如,我有一个包含 3 个字段的 solrdocmentlist,即 id、type 和 description。但是现在我想把返回的solrdocmentlist改成List,怎么办?下面的代码是返回的solrdocmentlist,如何将文档更改为List?
public SolrDocumentList searchSolr(String Keyword)
throws MalformedURLException, SolrServerException {
String _LOC = "[W_search: searchSolr]";
HttpSolrServer solr = new HttpSolrServer(
"http://localhost:8983/solr/collection1");
SolrQuery query = new SolrQuery();
query.set("q", "description:" + Keyword);
query.setStart(0);
query.setRows(6);
QueryResponse response = solr.query(query);
SolrDocumentList docs = response.getResults();
return docs;
}
由于 SolrDocumentList
扩展 ArrayList<SolrDocument>
实现 List
,
List<SolrDocument> list = docs;
应该可以解决问题。
例如,我有一个包含 3 个字段的 solrdocmentlist,即 id、type 和 description。但是现在我想把返回的solrdocmentlist改成List,怎么办?下面的代码是返回的solrdocmentlist,如何将文档更改为List?
public SolrDocumentList searchSolr(String Keyword)
throws MalformedURLException, SolrServerException {
String _LOC = "[W_search: searchSolr]";
HttpSolrServer solr = new HttpSolrServer(
"http://localhost:8983/solr/collection1");
SolrQuery query = new SolrQuery();
query.set("q", "description:" + Keyword);
query.setStart(0);
query.setRows(6);
QueryResponse response = solr.query(query);
SolrDocumentList docs = response.getResults();
return docs;
}
由于 SolrDocumentList
扩展 ArrayList<SolrDocument>
实现 List
,
List<SolrDocument> list = docs;
应该可以解决问题。