我在想如何更改以下代码,以便将Solr
的查询存储到ArrayList
?
public static void main(String[] args) throws MalformedURLException, SolrServerException {
HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr");
Scanner sc = new Scanner(System.in);
System.out.println("What are you looking for: ")
String look = sc.nextLine();
SolrQuery query = new SolrQuery();
query.setQuery(look);
query.setFields("id");
query.setStart(0);
QueryResponse response = solr.query(query);
SolrDocumentList results = response.getResults();
for (int i = 0; i < results.size(); ++i) {
System.out.println(results.get(i));
}
}
答案 0 :(得分:0)
你忘记了重要的部分..把信息放在列表中
假设 response.getResults()返回一个包含字符串的对象 那么你需要一个字符串列表:)
{{1}}