1

我尝试使用来自 solr wiki 的这个例子来模拟我的数据库。

我有一个名为 item 的表和一个名为 features 的表,其 id、featureName、description

这是更新的 xml(添加了 featureName)

<dataConfig>
<dataSource driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:/temp/example/ex" user="sa" />
<document>
    <entity name="item" query="select * from item">
        <entity name="feature" query="select description, featureName as features from feature where item_id='${item.ID}'"/>
    </entity>
</document>

现在我在 xml 元素中得到两个列表

<doc>
 <arr name="featureName">
  <str>number of miles in every direction the universal cataclysm  was  gathering</str>
  <str>All around the Restaurant people and things relaxed and chatted.  The</str>
  <str>- Do we have... - he put up a hand to hold back the cheers, -  Do  we</str>
 </arr>
 <arr name="description">
  <str>to a stupefying climax. Glancing at his watch, Max returned to  the  stage</str>
  <str>air was filled with talk of this and that, and with the mingled scents  of</str>
  <str>have a party here from  the  Zansellquasure  Flamarion  Bridge  Club  from</str> 
 </arr>
</doc>

但我想一起查看列表(使用 xml 属性),这样我就不必加入这些值。
可能吗?

4

1 回答 1

1

我想建议ScriptTransformer,它使您可以根据需要灵活地更改数据,但它不适用于您的情况,因为它在行级别工作。

您始终可以在 SQL(示例) 中为字符串连接定义聚合函数,但您可能会遇到性能问题。

如果您将使用http/xml数据源,则解决方案将是使用flatten属性。

尽管如此,即使您最终使用多值字段,搜索功能也会按预期工作。不利的一面是在客户端上,您将在表示层之前将它们连接起来,如果您使用某种分页,这并不是真正的问题。

于 2013-06-22T23:29:50.830 回答