У меня есть две таблицы клиентов и сборы, связанные 1xn по customer.id = fees.customerId
. сборы имеют две другие колонки, length
и rate
. Мой Solr конфигурация является:Как сохранить отношение полей в дочернем объекте
schema.xml
<schema name="customers" version="1.5">
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="id" type="long" indexed="true" stored="true"/>
<field name="customerName" type="string" indexed="false" stored="true"/>
<field name="length" type="int" indexed="false" stored="true" multiValued="true"/>
<field name="rate" type="float" indexed="false" stored="true" multiValued="true"/>
<uniqueKey>id</uniqueKey>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="string" class="solr.StrField"/>
</schema>
Solr-данных config.xml
<entity name="customer" query="SELECT * FROM customers">
<field column="id" name="id"/>
<field column="name" name="customerName"/>
<entity name="fees" query="SELECT length, rate FROM fees WHERE id=${customer.id}">
<field column="length" name="length"/>
<field column="rate" name="rate"/>
</entity>
</entity>
Проблема заключается в том, что из-за плоскую схемой в Solr, length
и rate
конца вверх «диссоциирована 'друг от друга, как два списка. Я хочу иметь один список пар, поэтому список <length, rate>
. Мое текущее решение состоит в том, чтобы изменить конфигурацию данных на
<entity name="fees" query="SELECT CONCAT(length, ';', rate) AS lengthRatePair FROM fees WHERE id=${customer.id}">
<field column="lengthRatePair" name="lengthRatePair"/>
</entity>
И затем на стороне клиента разделите поле на;. Но я думаю, что должно быть гораздо более элегантное решение.
Каков правильный способ сделать это?