Satchel
Satchel

Reputation: 16734

can I search for events based on time in neo4j?

I am using the neography gem hosted by GrapheneDB.

I need to send out recurring events.

What I did with my previous DB is check if object[:next_occurrence] is < TimeDate.now

I don't see how I can do this type of search in neo4j nor in the documentation:

  1. https://neo4j.com/developer/guide-sql-to-cypher/#_cypher_is_all_about_patterns
  2. https://github.com/maxdemarzi/neography/wiki/Scripts-and-queries

Upvotes: 0

Views: 46

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30417

Using just Cypher, you can use the timestamp() function to generate a unix timestamp in ms (representing the current instant), which you can store as a property on nodes or relationships.

That can let you run these kinds of comparisons. So if you have nodes with next_occurrence properties, and you already have an event variable bound to a particular node, you could use a predicate like:

...
WHERE event.next_occurrence < timestamp()
...

With an index on the label/property, these kinds of predicates can use the index to find starting nodes fast (all events in the past, in the future, or within ranges).

Upvotes: 0

Related Questions