使用useSolrAddSchema和嵌套实体的Solr DataImportHandler
我在使用Solr的DataImportHandler为Solr的add Schema中的XML文件编制索引时遇到问题,如果我通过HTTP更新请求发送它,我就能够为它编制索引 问题在于文档中的嵌套实体。我无法正确索引它们 下面是要编制索引的XML文件的示例:使用useSolrAddSchema和嵌套实体的Solr DataImportHandler,solr,dataimporthandler,Solr,Dataimporthandler,我在使用Solr的DataImportHandler为Solr的add Schema中的XML文件编制索引时遇到问题,如果我通过HTTP更新请求发送它,我就能够为它编制索引 问题在于文档中的嵌套实体。我无法正确索引它们 下面是要编制索引的XML文件的示例: <add commitWithin="5000"> <doc> <field name="id">1</field> <field name="type">Doc
<add commitWithin="5000">
<doc>
<field name="id">1</field>
<field name="type">Document</field>
<doc>
<field name="id">1_1</field>
<field name="nested_status">Nested</field>
</doc>
<field name="isParent">true</field>
</doc>
</add>
<dataConfig>
<dataSource name="Test_XML"
type="FileDataSource"
encoding="ISO_8859_1"/>
<document>
<entity name="doc"
processor="XPathEntityProcessor"
stream="true"
useSolrAddSchema="true"
url="LOCATION\useSolrAddSchema_test.xml">
<entity name="nested_doc"
processor="XPathEntityProcessor"
stream="true"
useSolrAddSchema="true"
child="true"
url=LOCATION\useSolrAddSchema_test.xml">
</entity>
</entity>
</document>
</dataConfig>
因此,它忽略了嵌套文档,当我查询以获取所有索引文档时,我得到了外部文档的两个副本:
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"indent":"on",
"wt":"json",
"_":"1477568715268"}},
"response":{"numFound":2,"start":0,"docs":[
{
"id":"1",
"type":"Document"},
{
"id":"1",
"type":"Document",
"_version_":1549343328462438400}]
}}
我已经研究了公认的答案是不可能有嵌套实体的地方,但是自从Solr 5.1以来,应该可以使用child='True'
atribute
我目前正在使用Solr版本6.2.1,但更喜欢与旧版本兼容的解决方案
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"indent":"on",
"wt":"json",
"_":"1477568715268"}},
"response":{"numFound":2,"start":0,"docs":[
{
"id":"1",
"type":"Document"},
{
"id":"1",
"type":"Document",
"_version_":1549343328462438400}]
}}