java-如何使用spring数据solr在solr中插入嵌套文档?
作者:互联网
我需要将这种数据插入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
}
没有装卸数据的情况下可以正常工作.但是不能作为嵌套文档插入.当我尝试时,就像这样插入
{
"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数据solr中使用这类嵌套文档呢?
解决方法:
是的,您可以插入嵌套的文档,请检查以下问题的答案:
SOLRJ-6.0.0: Insertion of a bean object which associate list of bean object is giving null pointer exception
标签:solrj,solr,spring-data-solr,spring,java 来源: https://codeday.me/bug/20191027/1940790.html