0

I want to import data from 1:n db relation i.e. Cars and CarParts tables.
Since I dont want to write a join over the the tables
(car id and name will be multiplied in the query and thus will be with a higher score in he query)
I am looking for the recommended way to represent in dataconfig and schema xml files 1:n connection.

4

1 回答 1

0

多值字段可以用来解决这个问题。

您的数据配置可能类似于:

...
<entity name="Cars" query="select carId, carName from Cars">

   <entity name="CarParts" query="select carPartName from CarParts 
                                    where carId = '${Cars.CarId}'">

  </entity>

</entity>
...

在您的模式文件中,将字段“carPartName”标记为多值。

<field name="carPartName" type="string" indexed="true" stored="true" multiValued="true" />

现在处理 1:n 关系,如果为每个“汽车”创建一个文档,则相应的“汽车零件”(可能不止一个)也是同一文档的一部分。

于 2013-06-19T03:25:33.147 回答