我已经成功地在solr中索引pojos但是从solr读取我的输出是错误的。 也许我打印的方式不正确。谁能告诉我如何解决这个问题? 我的代码如下:
List<SampleDocument> foundDocuments = response.getBeans(SampleDocument.class);
for(SampleDocument docs:foundDocuments) {
System.out.println(docs.getTitle());
}
打印输出后,我得到的都是空的。
SampleDocument.java
package solrobj.Asolrobj;
import java.util.List;
import org.apache.solr.client.solrj.beans.Field;
public class SampleDocument {
private int id;
private String title;
public SampleDocument() {
// required for solrj to make an instance
}
public SampleDocument(int id, String title) {
this.setId(id);
this.title = title;
}
public String getTitle() {
return title;
}
@Field("title")
public void setTitle(String title) {
this.title = title;
}
public int getId() {
return id;
}
@Field("tid")
public void setId(int id) {
this.id = id;
}
}
Schema.xml的
<field name="tid" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>
error