Solr,仅在日期时间字段中按时间搜索? [英] Solr, search only by time among datetime fields?

查看:364
本文介绍了Solr,仅在日期时间字段中按时间搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个结果列表:

{
    entry: 'name1',
    at: '2013-04-01 13:44:02'
},
{
    entry: 'name2',
    at: '2013-11-11 23:34:11'
},
{
    entry: 'name3',
    at: '2013-05-09 03:58:32'
},

现在,我想编写一个搜索过滤条件,其结果将在'12:00:00'和'14中命中: 00:00',因此按时间而不是日期进行过滤,而忽略日期本身。

now I would want to write a search filter condition that results hits in '12:00:00' and '14:00:00', so filtering in times, not dates, ignoring the date itself. Something like:

at:[*T12:00:00Z TO *T14:00:00Z]


推荐答案

然后,您需要将仅时间信息放在另一个字段中,例如色调,将时间设为单个整数,则12:44:32将为124432,那么您可以轻松地运行所需的范围查询。

then you need to put the time only information in another field, say a tint, making the time a single integer, 12:44:32 would be 124432 and then you can easily run the range queries you need.

要创建该时间字段,您需要几个选项:

To create that time field you have several options:


  1. 将其从客户端本身添加到文档中

  2. 使用copyField复制进入时间字段,然后使用 PatternReplaceFilter 来删除值的日期部分

  3. 在UpdateRequestProcessor中添加时间字段

  1. add it to the document from the client side itself
  2. use a copyField to copy into the time field, and use a PatternReplaceFilter to remove the date part of the value
  3. add the time field inside a UpdateRequestProcessor

1或2是迄今为止最简单的。

1 or 2 are the easiest by far.

这篇关于Solr,仅在日期时间字段中按时间搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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