在neo4j中,如何按日期索引并在日期范围内搜索? [英] In neo4j, how can I index by date and search in a date range?

查看:2197
本文介绍了在neo4j中,如何按日期索引并在日期范围内搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在neo4j中,我如何按日期索引并在日期范围内搜索。同样有时候,我想在日期范围内的早上8点到9点之间进行搜索。

In neo4j, how can I index by date and search in a date range. Also for times, I would like to search between 8am and 9am in a date range as well.

推荐答案

索引日期和时间作为整数时间戳。然后,您可以轻松地在索引中搜索其他时间戳之间的日期。您还可以将时间戳的时间部分分别索引为另一个整数,允许您查询给定日期之间的特定时间。

Index the dates and times as integer timestamps. Then you can easily search in an index for dates between other timestamps. You can also index the time part of the timestamp separately as another integer, allowing you to query for specific times between given dates.

示例:
日期和存储时间是2012-02-05 8:15 AM
所以在你的索引中,存储timestamp = 1328447700和time = 815

Example: The date and time to store is "2012-02-05 8:15 AM" So in your index, store "timestamp=1328447700" and "time=815"

现在,您要查询2012-02-01和2012-02-10之间从上午8:00到上午9:00发生的所有事件的索引。你可以通过查询索引
timestamp> = 1328072400和timestamp< = 1328936399,时间> = 800,时间< = 900

Now you want to query the index for all events between 2012-02-01 and 2012-02-10 that occurred from 8:00 am to 9:00 am. You do that by querying the index for "timestamp>=1328072400 and timestamp<=1328936399 and time>=800 and time<=900"

确切地说执行此操作的语法取决于您如何连接到Neo4j(REST或嵌入式)以及您正在使用的编程语言。但无论如何,这个想法都是一样的。

The exact syntax for doing this depends on how you are connecting to Neo4j (REST or embedded) and which programming language you are using. But the idea is the same in any case.

这篇关于在neo4j中,如何按日期索引并在日期范围内搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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