Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

geolocation - In solr dih import two double in one location

What I have now is the two double filds:

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

and what I want: the 2 double value in one location field:

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

What I tried so far and does't work:

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

Any simple solution? Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well, you where right @nikhil500. ScriptTransformer is one answer, (I'm not sure if this is the simpliest). The dataconfig.xml contains a java function:

<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 will be called:

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

Hope that will help others to solve this kind of problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...