索引索引我的SQL时间戳记或日期时间字段 [英] Solr Indexing My SQL Timestamp or Date Time field
本文介绍了索引索引我的SQL时间戳记或日期时间字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要索引Solr中的日期,日期应为ISO格式。
我可以使用修改SQL Select语句来索引MySQL Timestamp或Date Time feild吗?
To index Date in Solr, Date should be in ISO format. Can we index MySQL Timestamp or Date Time feild with out modifying SQL Select Statement ?
我已经使用了
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
<field name="CreatedDate" type="tdate" indexed="true" stored="true" />
CreatedDate is of Type Date Time in MySQL
我正在获得以下异常
11:23:39,117 WARN [org.apache.solr.handler.dataimport.DateFormatTransformer] (Thread- 72) Could not parse a Date field : java.text.ParseException: Unparseable date: "2013-04-14 11:22:48.0"
解决这个问题的任何帮助是非常感谢
Any help in fixing this Issue is really appreciated
推荐答案
检查SOLR中datetime字段的默认属性
Check Default nature of datetime field in SOLR
使用以下mysql函数转换您的datetime值
Convert Your datetime value with following mysql function
SELECT id,DATE_FORMAT(created_at,'%Y-%m-%dT%TZ') as created_at,... from table
这篇关于索引索引我的SQL时间戳记或日期时间字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文