例如,我有solrdocmentlist,其中包含3个字段,即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;
}
答案 0 :(得分:0)
由于SolrDocumentList
扩展了ArrayList<SolrDocument>
,后者实现了List
,
List<SolrDocument> list = docs;
应该可以解决问题。