Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Localization 如何使用DIH、CopyField或sql cast运算符将2个字符串转换为Solr位置数据字段?_Localization_Solr_Dih - Fatal编程技术网

Localization 如何使用DIH、CopyField或sql cast运算符将2个字符串转换为Solr位置数据字段?

Localization 如何使用DIH、CopyField或sql cast运算符将2个字符串转换为Solr位置数据字段?,localization,solr,dih,Localization,Solr,Dih,我在schema.xml中有以下内容: <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"

我在
schema.xml中有以下内容:

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

我设法从DB导入lat,只要字符串:

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

如何使用简单的解决方案复制/转换两次穿刺

更新1: 好的,从string到double的转换成功了,非常感谢您的解决方案!我现在有两个双字段:

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


有简单的解决办法吗?提前谢谢

您可以在schema.xml文件中使用copyField,如下所示:

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

您可以在schema.xml文件中使用copyField,如下所示:

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


将自动进行转换?将自动进行从字符串到双精度的转换。当我现在仔细查看您的x_geo字段时,我不确定是否会转换,除非您在x_geo_str中将字符串值存储为类似于0.0,0.0的值,否则可能会正确转换。但是,我不能确定,因为您将x_geo_str存储为多值。我不能用这种方法解决我的问题(只是部分),但另一种方法可以是:(我不确定这是否是最简单的方法,但它对我有效)。希望它会有用。转换将自动进行。从字符串到双精度的转换将自动进行。当我现在仔细查看您的x_geo字段时,我不确定是否会转换,除非您在x_geo_str中将字符串值存储为类似于0.0,0.0的值,否则可能会正确转换。但是,我不能确定,因为您将x_geo_str存储为多值。我不能用这种方法解决我的问题(只是部分),但另一种方法可以是:(我不确定这是否是最简单的方法,但它对我有效)。希望它会有用