我的数据导入处理程序文档如下:
<document>
<entity name="product" query="SELECT
id,
sku,
name,
image FROM products">
<field column="id" name="id" />
<field column="sku" name="sku" />
<field column="name" name="name" />
<field column="image" name="image" />
<entity name="rates" child="true" query="select start_date, end_date, price from product_rates where product_id='${product.id}'">
<field name="start_date" column="start_date" />
<field name="end_date" column="end_date" />
<field name="price" column="price" />
</entity>
</entity>
</document>
当我设置child = true文档时子数据没有插入solr。我需要在schema或solrconfig中进行任何更改才能插入子doc。 我使用的是solr 6.3,我的schema.xml如下:
<schema name="product" version="1.5">
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<!--PARENT DOC-->
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="sku" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="name" type="text_general" indexed="false" stored="true" multiValued="false" />
<field name="image" type="text_general" indexed="false" stored="true" multiValued="false" />
<!--CHILD DOC-->
<field name="start_date" type="date" indexed="false" stored="true" multiValued="false" />
<field name="end_date" type="date" indexed="true" stored="true" multiValued="false" />
<field name="price" type="tdouble" indexed="true" stored="true" multiValued="false" />
<uniqueKey>id</uniqueKey>
<defaultSearchField>id</defaultSearchField>
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD" currencyConfig="currency.xml" />
</schema>
答案 0 :(得分:0)
通过向Entity处理器添加“child = true”参数。
启用索引文档块,即嵌套子文档,以便使用块连接查询解析器进行搜索。它只能在另一个根实体下指定。它从默认行为(合并字段值)切换到嵌套文档作为子文档。注意:父级应添加一个在查询时间内用作父级过滤器的字段。