Multilevel index and TimelineIndex

164 views
Skip to first unread message

Luanne Coutinho

unread,
Oct 15, 2012, 12:06:21 AM10/15/12
to ne...@googlegroups.com
Hi,

I was going to use the multilevel index described in http://docs.neo4j.org/chunked/milestone/cypher-cookbook-path-tree.html tie events to a timeline and write queries to fetch certain types of events within a date range.
Noticed that there is a LuceneTimeline in org.neo4.index.lucene.
It appears that this is useful for getting all entities within a range irrespective of the type of entity (determined by relations/properties etc)?
Is there any place that has more documentation/examples/usage for LuceneTimeline? Would like to understand fully what it's used for before I go build a multilevel index.

Thanks
Luanne

Mattias Persson

unread,
Oct 15, 2012, 7:19:56 AM10/15/12
to ne...@googlegroups.com
LuceneTimeline is just a tiny abstraction of a normal index where it indexes entities given timestamps, using the numerical functionality of Lucene (and inherently the Lucene backed neo4j indexes). Also querying uses Lucene range queries to find the entities within the given timestamps. All that's in there can be done using normal Lucene backed neo4j indexes. See https://github.com/neo4j/community/blob/master/lucene-index/src/main/java/org/neo4j/index/lucene/LuceneTimeline.java

2012/10/15 Luanne Coutinho <luanne....@gmail.com>

Luanne

--
 
 



--
Mattias Persson, [mat...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com

Luanne Coutinho

unread,
Oct 15, 2012, 7:38:36 AM10/15/12
to ne...@googlegroups.com
Hmm so I can just as well index various events by type, and use this to fetch them.
Are there any performance gains/losses using one way or the other?

I think initially, for a spike, the LuceneTimeline will be simple enough. If my timeline grows to be more complicated, I can always introduce the multilevel index.

Thanks
Luanne

--
 
 

Luanne Coutinho

unread,
Oct 17, 2012, 2:28:21 PM10/17/12
to ne...@googlegroups.com
Mattias, how do I get a handle back to a LuceneTimeline I've created? I just see a constructor.

Thanks
Luanne

Mattias Persson

unread,
Oct 24, 2012, 1:54:10 PM10/24/12
to ne...@googlegroups.com
That sounded like a pretty basic Java question, am I right? You construct the timeline index and keep a reference to it, which you use for adding, removing and querying the timeline index. Like so:

  TimelineIndex index = new LuceneTimeline( db, db.index().forNodes( "my-timeline" ) );
  // and then later on adding to it...
  index.add( myNode, timestampForMyNode );

2012/10/17 Luanne Coutinho <luanne....@gmail.com>

Luanne Coutinho

unread,
Oct 24, 2012, 10:11:32 PM10/24/12
to ne...@googlegroups.com
No, didn't mean that...I can create the index and add stuff to it. Question is do I need to keep like a static reference to it to be accessed in other parts of the application? Or if my app and db are shut down, how do I get back my index (just like you can do db.index().forNodes(regular neo4j index))? The LuceneTimeline does not seem to be named so not sure how I get it back to actually query it.

Hope this explanation is clearer :-)

Regards
Luanne


--
 
 

Mattias Persson

unread,
Oct 25, 2012, 4:23:59 AM10/25/12
to ne...@googlegroups.com


2012/10/25 Luanne Coutinho <luanne....@gmail.com>

No, didn't mean that...I can create the index and add stuff to it. Question is do I need to keep like a static reference to it to be accessed in other parts of the application? Or if my app and db are shut down, how do I get back my index (just like you can do db.index().forNodes(regular neo4j index))? The LuceneTimeline does not seem to be named so not sure how I get it back to actually query it.

Hope this explanation is clearer :-)

Now it's crystal clear, thanks. So... a LuceneTimeline has no state of its own, it's merely a wrapper around a Lucene backed org.neo4j.graphdb.index.Index hence it's perfectly fine to create new instances over time. Even one per add/remove/query should work.

Luanne Coutinho

unread,
Oct 25, 2012, 4:27:46 AM10/25/12
to ne...@googlegroups.com
Ah okay, I shall try it out, thank you!

--
 
 

Reply all
Reply to author
Forward
0 new messages