Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top