2012-07-23 41 views
1

我有一个多值字段Solr的数据导入多值字段到一个单一的值域

<arr name="colors"> 
<str>Blue</str> 
<str>Red</str> 
<str>Orange</str> 
<str>Pink</str> 
<str>Violet</str> 
</arr> 

填充像这样:

<entity name="pub_attributes" query=" SELECT name [description] FROM dbo.Colors"> 
     <field name="colors" column="description" /> 
</entity> 

我需要另一个领域的所有颜色,但只有一条线通过空格分开像

<str name="Colors_All">Bue Red Orange Pink Violet</str> 

我怎么能做到这一点无需从头再来访问色彩表? 也许这样的事情

<entity name="Properites_all" query=" 
    DECLARE @all VARCHAR(MAX) 
    SET @all = ''  
    Select @all = @all + ... from '${pub_attributes.colors}' 

    UNION 
    Another SELECT that will add more info than just the colors 
"> 
    <field name="colors_all" column="description" /> 
</entity> 
+1

你能接受一些你以前得到的答案吗? – javanna 2012-07-24 07:50:42

回答

0

我想,你在寻找什么是copyfield: copyfield wiki,你也可以到这里看看:how to use it 希望这将有助于。

+0

我试过,但从多值复制到单值不工作,再加上,我需要添加额外的信息字段“Colors_All”,这就是为什么我需要在查询中引用“颜色”属性之后,我可以添加更多的话。不管怎么说,还是要谢谢你! – Nicole 2012-07-25 15:15:26

+2

在这种情况下,如果您使用DIH(数据导入器处理程序)进行导入,则可以在导入/索引时使用scriptTransformer:[link](http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer) – vuky 2012-07-26 05:46:20