我正在尝试通过 DIH 使 solr 字段的值包含有关 XML 中父子关系的信息。
这是数据配置:
<dataConfig>
<script>
<![CDATA[
function doSomething(row){
//logic
return row;
}
]]>
</script>
<dataSource type="URLDataSource"/>
<document>
<entity name="getModels"
pk="id"
url="pathpathpath"
processor="XPathEntityProcessor"
forEach="/path"
transformer="script:doSomething"
>
<field column="spec" xpath="/Group/name/SubGroup" transformer="script:doSomething"/>
<field column = ... />
</entity>
</document>
示例 XML:
<Group>
<name>
Vehicle
</name>
<SubGroup>
<name>Car</name>
</SubGroup>
<SubGroup>
<name>Bike</name>
</SubGroup>
</Group>
<Group>
<name>
Fruit
</name>
<SubGroup>
<name>Apple</name>
</SubGroup>
<SubGroup>
<name>Banana</name>
</SubGroup>
</Group>
我将如何指定:
<field column="spec" xpath="/Group/name/SubGroup" transformer="script:doSomething"/>
这样我就可以拥有相应的规范实例:
Vehicle Car
和
Vehicle Bike
和
Fruit Apple
和
Fruit Banana
理想情况下,名称和子名称之间有一个分隔符,例如:
Fruit::Banana