1

I have a MySql database from which I need to fetch data into Solr that is normalized in MySql over several tables. For example, I have an 'articles' table that have a 'companyId' column. 'companyIds' are linked to 'companyName' in a second table 'company'. So in order to be able to find articles by company name using Solr I need to denormalize when building the Solr index.

What is the easiest way to do this? Can denormalization be done in the data source configuration or do I need to denormalize prior to creating the index?

Feeding data using Solrj and normalizing while doing it seems to be the easiest method I can come up with at the moment (although it seems unnecessary if Solr has those features).

4

1 回答 1

1

啊,我在数据导入处理程序的文档中找到了我想要的东西。可以使用下面的“子实体”查询来提取对包含在当前表中找到的引用值的表的查询。

通过使用父实体/查询中的 category_id 从类别表中选择来解析项目的类别名称:

<entity name="item_category" query="select category_id from item_category where item_id='${item.id}'">
    <entity name="category" query="select description from category where id = '${item_category.category_id}'">
                <field column="description" name="cat" />
    </entity>
</entity>

来自这里的 XML: http ://wiki.apache.org/solr/DataImportHandler#Full_Import_Example

于 2012-09-27T13:16:37.503 回答