我有下面的 bean 类来定义我的 solrInputDocument
public class VenueDocumentSolr extends SolrInputDocument {
@Field
private int id;
@Field
private String uid;
...
}
我尝试使用以下代码获取结果:
SolrQuery query = new SolrQuery();
query.setQuery(SearchForRestaurants);
QueryResponse rsp = SolrUtil.issueSolrQuery(query);
for (SolrDocument s : rsp.getResults())
System.out.println(s);
List<VenueDocumentSolr> beans = rsp.getBeans(VenueDocumentSolr.class);
上面的代码有时会起作用,并在其余时间抛出下面的异常。
我交叉检查并将缺少的字段添加到我的 bean 类中。但是没有用。我仍然收到错误:(
org.apache.solr.client.solrj.beans.BindingException: Could not instantiate object of class com.zvents.common.entities.solr.VenueDocumentSolr
at org.apache.solr.client.solrj.beans.DocumentObjectBinder.getBean(DocumentObjectBinder.java:68)
at org.apache.solr.client.solrj.beans.DocumentObjectBinder.getBeans(DocumentObjectBinder.java:47)
at org.apache.solr.client.solrj.response.QueryResponse.getBeans(QueryResponse.java:480)
at com.zvents.webapp.api.DeleteData.QueryAndUpdateVenuesForSearch(DeleteData.java:117)
.........
引用 Schema 的一部分
<int name="has_images">*</int>
<arr name="cuisine">
<str>*</str>
</arr>
<arr name="venue_type">
<int>*</int>
</arr>
<double name="location_0_latLon">*</double>
<float name="venue_imp">*</float>
<date name="last_indexed">*</date>
引用 bean 类中的适用字段
@Field
private int has_images;
@Field
private List<String> cuisine;
@Field
private List<Integer> venue_type;
@Field
private double location_0_latLon;
@Field
private float venue_imp;
@Field
private String last_indexed;