首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用DIH或版权或sql cast运算符将2个字符串转换为Solr位置数据字段?

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

Stack Overflow用户
提问于 2011-11-14 13:26:04
回答 1查看 998关注 0票数 1

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

代码语言:javascript
运行
复制
<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"/>

我成功地从数据库中导入了lat,只要是字符串:

代码语言:javascript
运行
复制
<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: Ok,从string到double的转换非常有效,非常感谢您的解决方案!我现在有两份双份文件:

代码语言:javascript
运行
复制
<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双值:

代码语言:javascript
运行
复制
<field name="x_geo" type="location" indexed="true" stored="true" default="0.0,0.0"/>

到目前为止,我尝试过的却没有用:

代码语言:javascript
运行
复制
<copyField source="*_coordinate" dest="x_geo"/>
<copyField source="x_geo_str" dest="x_geo"/>

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-14 13:34:40

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

代码语言:javascript
运行
复制
  <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"/>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8122255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档