2011-11-15 10 views
6

私が今持っていることは2重fildsです:1つの場所でダブル2をインポート

<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"/> 

と、私が欲しいもの:1つの場所フィールドで2 double値:

<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"/> 

簡単な解決方法はありますか?前もって感謝します!

答えて

3

まあ、あなたはどこに@ nikhil500の権利がありますか。 ScriptTransformerは1つの答えです(これが最もシンプルなのかどうかはわかりません)。 whitch呼ばれる

<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; 
      } 
]]> 

<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> 

希望他人を助けるこの種の問題を解決するdataconfig.xmlは、Javaの機能が含まれています。 DIHで

0

ScriptTransformerを使用してx_geoフィールドを作成することができます。

+0

私に短い例を教えてもらえますか? – vuky

2

使用TemplateTransformer(データ-config.xmlの):

<entity name="p" transformer="TemplateTransformer" ...... 
<field column="location" template="${p.location_0_coordinate},${p.location_1_coordinate}" /> 
2

PaulGの答えに加えて、あなたはマルチ値をサポートする、Solrの4にlocation_rptを使用することができますが、宣言する必要はありません。 MultiValueとして

<field name="region" type="location_rpt" indexed="true" stored="true" />