solr4.9--》dataimport导入数据类型转换问题
发布日期:2021-07-22 16:17:21 浏览次数:1 分类:技术文章

本文共 1808 字,大约阅读时间需要 6 分钟。

本说明以solr4.9为例进行:

在用dataimport进行数据库(oracle)索引导入的时候发现数据库的date类型和clob类型始终无法生成索引,反复测试得出如下解决办法。

1:date类型索引解决办法

将data类型用to_char进行转换,然后索引用type类型用string类型接收即可。后台查询索引的时候,直接再把string类型的date转换为date即可。

例如:select id,name,sex,blog as blog_article,type,to_char(create_time,'yyyy-mm-dd hh24:mi:ss') create_time,solr_time,recycle_flag,'demo_flag' as searchFlag from demo

这里的create_time即为oracle表的date类型。

schema.xml中直接用string类型接收。如下:

<field name="create_time" type="string" indexed="true" stored="true"/>

2:clob类型索引解决办法

在entity上添加transformer="ClobTransformer"  然后在field上添加 clob="true" 具体如下:

<entity name="demo" transformer="ClobTransformer" pk="ID" dataSource="projectV2" 

query="select id,name,sex,blog as blog_article,type,to_char(create_time,'yyyy-mm-dd hh24:mi:ss') create_time,solr_time,recycle_flag,'demo_flag' as searchFlag from demo"
deletedPkQuery="select id from demo where recycle_flag=1"
deltaQuery="select id from demo where to_char(solr_time,'yyyy-mm-dd hh24\:mi\:ss') > '${dataimporter.last_index_time}'"
deltaImportQuery="select id,name,sex,blog as blog_article,type,to_char(create_time,'yyyy-mm-dd hh24:mi:ss') create_time,solr_time,recycle_flag,'demo_flag' as searchFlag from demo where id='${dataimporter.delta.ID}'">
 <field column="id" name="id"/> 
 <field column="name" name="name" />
 <field column="sex" name="sex" />
 <field column="BLOG_ARTICLE" name="blog_article"  clob="true" />
 <field column="type" name="type" />
 <field column="create_time" name="create_time"/>
 <field column="solr_time" name="solr_time"/>
 <field column="recycle_flag" name="recycle_flag" />
  </entity>

clob类型索引的时候特别需要提醒注意的是如下内容,这里以我测试的blog_article为例说明:

BLOG_ARTICLE的数据库字段为BLOG,但是如果你用BLOG去进行索引clob字段的时候发现无法索引,会变成oracle.sql.CLOB@1042c25。所以得出如下结论:

数据库中Clob字段名不能与schema.xml中对应的字段同名。否则,Colb字段导入的结果为<str name="abc">oracle.sql.CLOB@1042c25</str>

转载地址:https://blog.csdn.net/makang110/article/details/51028733 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:CentOS 6 安装VMWare tools,以及解决安装后/mnt中有hgfs但没共享文件的方法
下一篇:Web客户端安全性最佳实践

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月17日 07时55分03秒