1

I have in schema.xml the followings:

<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"/>
<field name="x_geo" type="location" indexed="true" stored="true" default="0.0,0.0"/>

and I managed to import from a DB the lat, long as strings:

<field name="x_geo_x_str_coordinate_s" type="string" indexed="true" stored="true" default="0"/>
<field name="x_geo_y_str_coordinate_s" type="string" indexed="true" stored="true" default="0"/>
<field name="x_geo_str" type="string" indexed="true" stored="true" multiValued="true" default="0,0"/>

How can I copy/convert the 2 stings in double with a simple solution?

Update 1: Ok, the convertion from string to double has worked corectly, and thanks a lot for the solution! 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!

vuky
  • 583
  • 6
  • 19

1 Answers1

1

You can use the copyField as follows in your schema.xml file:

  <copyField source="x_geo_x_str" dest="x_geo_x_coordinate"/>
  <copyField source="x_geo_y_str" dest="x_geo_y_coordinate"/>
  <copyField source="x_geo_str" dest="x_geo"/>
Paige Cook
  • 22,415
  • 3
  • 57
  • 68
  • the conversion will be made automaticaly? – vuky Nov 14 '11 at 13:39
  • The conversion from string to double will be made automatically. As I look closer now at your x_geo field, I am not sure that one will convert, unless you are storing the string value in x_geo_str as something like 0.0,0.0 then that might convert correctly. However, I cannot tell for sure, since you are storing x_geo_str as multiValued. – Paige Cook Nov 14 '11 at 13:43
  • I can't resolve my problem in that way (just partialy), but an alternative could be: http://stackoverflow.com/questions/8134958/in-solr-dih-import-two-double-in-one-location (I not sure if this is the easiest way to do it, but it worked for me). hope it will be usefull – vuky Nov 17 '11 at 11:17