SolrServer solrserver = new HttpSolrServer( SOLR_URL );
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
List<MovieInfo> movielist = new ArrayList<MovieInfo>();
try {
QueryResponse rsp = solrserver.query(query);
SolrDocumentList docs = rsp.getResults();
for (SolrDocument doc : docs)
{
String name = (String) doc.getFieldValue("videoname");
String url = (String) doc.getFieldValue("videourl");
//capture image urls
Collection<Object> imgurls = doc.getFieldValues("captureurls");
String[] sImgurls = new String[imgurls.size()];
int iImgurl = 0;
for( Object imgurl : imgurls )
{
sImgurls[iImgurl++] = (String)imgurl;
}
MovieInfo movieinfo = new MovieInfo();
movieinfo.setName(name);
movieinfo.setUrl(url);
movieinfo.setImgurl(sImgurls[0]);
movielist.add(movieinfo);
}
} catch (SolrServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
要用collection<Object>去接收multiValued的返回值