我需要将此类数据插入到solr服务器。
{
"id":"09123"
"firstName": "Harshana651175279",
"lastName": "Samaranayake332146645",
"department": {
"id":"001",
"depName":"dep01"
}
}
这些是我用于插入数据的POJO。
public class SolrCustomer {
@Id
@Indexed
private String id;
@Field
@Indexed
private String firstName;
@Field
@Indexed
private String lastName;
@Field
private Department department;
//getters n setters
}
public class Department {
@Id
@Indexed
private String id;
@Field
@Indexed
private String departmentName;
//getters n setters
}
没有deparment数据其工作正常。但是不能作为嵌套文档插入。当我尝试它时,就像这样插入
{
"firstName": "Harshana651175279",
"lastName": "Samaranayake332146645",
"department": [
"org.ftm.solr.domain.Department@479c1814"
],
"id": "2e204ab3-772d-4af1-a2be-866e21206ecd",
"_version_": 1536317096485453800
}
这是我为此配置的架构。
<field name="department" type="strings" multiValued="true"/>
<field name="firstName" type="strings" multiValued="false"/>
<field name="id" type="string" indexed="true" required="true" stored="true"/>
<field name="lastName" type="strings" multiValued="false"/>
那么如何使用solr n spring data solr这些嵌套文档?
答案 0 :(得分:4)