2011-11-15 9 views
6

क्या मैं अब दो डबल filds है:Solr Dih में एक स्थान में दो डबल आयात

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

कोई आसान समाधान? अग्रिम में धन्यवाद!

उत्तर

3

ठीक है, आप कहां सही @ nikhil500। ScriptTransformer एक उत्तर है, (मुझे यकीन नहीं है कि यह सबसे आसान है)।

<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 बुलाया जाएगा:

<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 एक जावा समारोह में शामिल है।

0

x_geo फ़ील्ड बनाने के लिए आप ScriptTransformer का उपयोग कर सकते हैं।

+0

क्या आप मुझे एक छोटा सा उदाहरण दे सकते हैं, कृपया? – vuky

2
DIH (डेटा-config.xml) में

उपयोग TemplateTransformer:

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

PaulG का जवाब है, तो आप Solr 4, जो बहु मूल्यों का समर्थन करता है में location_rpt उपयोग कर सकते हैं, लेकिन जरूरत नहीं है के अलावा घोषित करने की मल्टीवैल्यू के रूप में।

<field name="region" type="location_rpt" indexed="true" stored="true" /> 
संबंधित मुद्दे