我已经成功地在 solr 中索引了 pojos,但是从 solr 读取时我的输出是错误的。也许我打印的方式不正确。谁能告诉我如何解决这个问题?我的代码如下:
List<SampleDocument> foundDocuments = response.getBeans(SampleDocument.class);
for(SampleDocument docs:foundDocuments) {
System.out.println(docs.getTitle());
}
打印输出后我得到的都是空的。
示例文档.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;
}
}
架构.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