如何使用 DIH 或 copyfiled 或 sql 转换运算符将 2 个字符串转换为 Solr 位置数据字段?
我在 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"/>
并且我设法从数据库导入纬度、长度作为字符串:
<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"/>
如何使用简单的解决方案将 2 个字符串复制/转换为双倍?
更新1: 好的,从字符串到双精度的转换已经正确工作,非常感谢您的解决方案!我现在拥有的是两个双字段:
<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"/>
任何简单的解决方案?提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 schema.xml 文件中使用 copyField,如下所示:
You can use the copyField as follows in your schema.xml file: