Solrインデックスに入れたいデータを含む正規化されたテーブルがあります。これに似たものです
+----+--------------+--------------+---------+
| id | name | attribute | value |
+----+--------------+--------------+---------+
| 1 | Apple | color | green |
| 1 | Apple | shape | round |
| 1 | Apple | origin | Belgium |
| 2 | Motorbike | type | fast |
| 2 | Motorbike | nr of wheels | 2 |
| 3 | Office chair | color | grayish |
| 3 | Office chair | spins | yes |
+----+--------------+--------------+---------+
ここで、一意の ID (アイテム) ごとに 1 つのドキュメントとしてインデックスを作成することをお勧めします。ただし、n 個の属性を 1 つのドキュメントに統合する必要があります。これを行うには、dataConfig で魔法をかける必要があります。しかし、n 個のフィールドをどのように格納してマップすることができるでしょうか? 今が動的フィールドを使用する適切な時期ですか?
これが私の現在の試みです。私はそれが有効ではないと確信しています。
<dataConfig>
<dataSource
type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mystuff"
user="root" password="*****"/>
<document name="doc">
<entity name="t1" query="select * from item_to_id_table">
<field name="id" column="id"/>
<field name="name" column="name"/>
<entity name="t2" query="select * from my_flat_table"
cacheKey="t1.id"
cacheLookup="t2.id">
<!-- alt 1 -->
<field name="$(t2.attribute)" column="value" />
<!-- alt 2 -->
<entity name="properties" query="select property, value from t2"
cacheKey="$(t2.attribute)"
cacheLookup="property">
<field name="$(properties.property)" column="value" />
</entity>
</entity>
</entity>
</document>
</dataConfig>
2 つの選択肢のどちらも有効ではないと確信しています。より良い方法が見つからない限り、すぐに試してみます。おそらく、3 番目の選択肢としてのスクリプト変換です。
この使用例は、Solr で使用するのに妥当ですか?