6

我现在拥有的是两个双重领域:

<field name="x_geo_x_coordinate" type="double" indexed="true" stored="true" default="0"/> 
<field name="x_geo_y_coordinate" type="double" indexed="true" stored="true" default="0"/>

以及我想要的:一个位置字段中的 2 个双精度值:

<field name="x_geo" type="location" indexed="true" stored="true" default="0.0,0.0"/>

到目前为止我尝试过并且不起作用的方法:

<copyField source="*_coordinate" dest="x_geo"/>
<copyField source="x_geo_str" dest="x_geo"/>

有什么简单的解决办法吗?提前致谢!

4

4 回答 4

3

好吧,你在哪里对@nikhil500。ScriptTransformer 是一个答案,(我不确定这是否是最简单的)。dataconfig.xml 包含一个 java 函数:

<script><![CDATA[
            function puttwodouble(row)        {
                var attrVal1 = row.get("GEO_X_WERT");
                var attrVal2 = row.get("GEO_Y_WERT");
                var attrVal = attrVal1 + "," + attrVal2;
                var arr = new java.util.ArrayList()
                arr.add(attrVal1);
                arr.add(attrVal2);
                row.put("store",attrVal);
                row.put("x_geo_str",arr);  
                return row;
            }
]]>

whit 将被称为:

 <entity name="inner_geo_str" transformer="script:puttwodouble"
            query="select GEO_X_WERT, GEO_Y_WERT from FIRMA_GEODATEN where GEO_FIR_NR ='${outer.FIR_NR}' and geo_x_wert != 'NF'">                     
                  <field column="GEO_X_WERT" name="x_geo_x_s"/> 
                  <field column="GEO_Y_WERT" name="x_geo_y_s"/>                     
          </entity>

希望能帮助其他人解决这类问题。

于 2011-11-16T11:51:50.763 回答
2

在 DIH (data-config.xml) 中使用 TemplateTransformer:

<entity name="p" transformer="TemplateTransformer" ......
<field column="location" template="${p.location_0_coordinate},${p.location_1_coordinate}" />
于 2012-09-17T20:54:13.517 回答
2

除了 PaulG 的 answer 之外,还可以使用Solr 4 中的location_rpt,它支持多值,但不需要声明为 MultiValue。

<field name="region" type="location_rpt" indexed="true" stored="true" />
于 2013-05-30T11:55:29.017 回答
0

您可以使用ScriptTransformer创建x_geo字段。

于 2011-11-15T11:29:30.103 回答