Solr模式中的datetime字段 [英] datetime field in solr schema

查看:313
本文介绍了Solr模式中的datetime字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Solr在我的数据库上进行搜索,我需要从mysql数据库中获取一个具有(datetime)数据类型的字段,因此我将选择查询设置为在dataconfig.xml中获取此字段,并添加了字段在schema.xml中此字段的名称,如下所示:

I am using Solr to make search on my database, and i need to get a field with (datetime) data type from mysql database, so i set the select query to get this field in dataconfig.xml, and i added field name for this field in schema.xml as follow:

<field name="parsed_at" type="datetime" indexed="true" stored="true" />

<field name="parsed_at" type="datetime" indexed="true" stored="true" />

但是在这些修改之后,solr并没有做任何索引. 我试图

but solr didn't do any indexing after these modifications. i have tried to


select date(parsed_at) as parsed_at ...

,并在schema.xml中将类型指定为日期,但是由于未知原因,此方法不起作用
solr是否支持与mysql中的datatime或timestamp兼容的任何数据类型?

and to specify type as date in schema.xml, but this didn't work for unknown reason
does solr support any data type compatible with datatime or timestamp in mysql??

推荐答案

Solr与MySQL表中的典型MySql日期格式兼容,例如Y-m-d(依此类推) 如果MySQL中的parsed_at列来自类型datetime,那么只要您的字段名(solr)=场名(MySQL),您就无需在选择时间进行任何修改.

Solr is compatible with typical MySql date formats in an MySQL table, like Y-m-d (and so on) If parsed_at column in MySQL is from type datetime, so you don't need any modifications on select time, as long your field name(solr)=cloumn name(MySQL).

所以尝试select parsed_at from .... Solr将处理日期

So try select parsed_at from .... Solr will process the date

<field name="parsed_at" type="datetime" indexed="true" stored="true" />

请确保存在Solr的schema.xml中的fieldType(type =)datetime.如果是这样,请在此处发布配置.如果不是,请检查是否在schema.xml中退出以下行,这是默认值:

Be sure, that an fieldType (type=)datetime in Solr's schema.xml exits. If it is so, please post the configuration here. If not, check if, the following line exits in schema.xml, which is default:

<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

字段类型tdate可以处理日期格式. 如果您在schema.xml中具有此字段定义,则parsed_at字段可以使用该类型:

Field type tdate can handle date-formats. If you have this field definition in your schema.xml, your parsed_at field could use that type:

<field name="parsed_at" type="tdate" indexed="true" stored="true" />

这篇关于Solr模式中的datetime字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆