2011-11-15 19 views
6

Những gì tôi có bây giờ là hai filds kép:Trong dih Solr nhập hai đôi tại một địa điểm

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

và những gì tôi muốn: 2 giá trị tăng gấp đôi trong lĩnh vực một địa điểm:

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

Những gì tôi đã thử cho đến nay và không hoạt động:

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

Bất kỳ giải pháp đơn giản nào? Cảm ơn trước!

Trả lời

3

Vâng, bạn có quyền @ nikhil500. ScriptTransformer là một câu trả lời, (Tôi không chắc chắn nếu điều này là đơn giản nhất). Các dataconfig.xml chứa một hàm 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; 
      } 
]]> 

whitch sẽ được gọi là:

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

Hy vọng rằng sẽ giúp đỡ người khác để giải quyết các loại vấn đề.

2

Sử dụng TemplateTransformer trong DIH (data-config.xml):

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

Ngoài câu trả lời PaulG, bạn có thể sử dụng location_rpt trong Solr 4, hỗ trợ các giá trị đa, nhưng không cần phải được khai báo như MultiValue.

<field name="region" type="location_rpt" indexed="true" stored="true" /> 
Các vấn đề liên quan