Solr: How distinguish between multiple entities imported through DIH

家住魔仙堡 提交于 2019-12-24 07:06:04

问题


When using DataImportHandler with SqlEntityProcessor, I want to have several definitions going into the same schema with different queries.

How can I search both type of entities but also distinguish their source at the same time. Example:

<document>
<entity name="entity1" query="query1">

    <field column="column1" name="column1" />
    <field column="column2" name="column2" />

</entity>
<entity name="entity2" query="query2">

    <field column="column1" name="column1" />
    <field column="column2" name="column2" />

</entity>
</document>

How to get data from entity 1 and from entity 2?


回答1:


As long as your schema fields (e.g. column1, column2) are compatible between different entities, you can just run DataImportHandler and it will populate Solr collection from both queries.

Then, when you query, you will see all entities combined.

If you want to mark which entity came from which source, I would recommend adding another field (e.g. type) and assigning to it different static values in each entity definition using TemplateTransformer.

Also beware of using clean command. By default it deletes everything from the index. As you are populating the index from several sources, you need to make sure it does not delete too much. Use preImportDeleteQuery to delete only entries with the same value in the type field that you set for that entity.



来源:https://stackoverflow.com/questions/14627953/solr-how-distinguish-between-multiple-entities-imported-through-dih

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!