Neo4j BatchInserter and TimelineIndex [v1.9.4]

135 views Asked by At

I am using BatchInserterIndex to ingest a large amount of data to Neo4j DB. I intend to add nodes to a TimelineIndex (Lucene) during the batch. Now, in the normal way, TimelineIndex takes (node, long) to add in the index. It probably is using the key 'timestamp' internally. (Checked in LuceneTimeline.java in github)

My problem is that I'm able to insert nodes into the TL index but not able to retrieve them using the regular java API. It always returns timelineIndex.getFirst() as null. I have initialized the indices as below.

Regular Way Of Access

TimelineIndex<Node> timelineIndex = new LuceneTimeline<Node>(graphDB, indexMgr.forNodes("airing-timeline")); //graphDb initialised properly earlier.
timelineIndex.add(node, 1234560000L);

Batch Ingestion

BatchInserterIndex timelineIndex = indexProvider.nodeIndex("airing-timeline", MapUtil.stringMap("type", "exact")); //Initialised just like regular way

Map<String, Object> timelineIndexPropertiesMap = new HashMap<String, Object>();
timelineIndexPropertiesMap.put("timestamp", 1234560000L); //Checked the code of LuceneTimeline.java and found this internal property for timeline
timelineIndex.query("*:*").size(); // return 0 (zero)
timelineIndex.add(airing_node_id, timelineIndexPropertiesMap);
timelineIndex.query("*:*").size(); // return 1 (one)

Now, when I'm trying to use, timelineIndex.getFirst() to retrieve data added by Batch Inserter, it always returns me null. But, nodes added in the regular way on the SAME DB return me proper values.

Where am I going wrong?

1

There are 1 answers

0
jsanjayce On BEST ANSWER

In BatchInserterIndex method of inserting into timelineindex, the key would be "timestamp" and the value should be an instance of ValueContext of type numeric. So, you need to call static function ValueContext.numeric(value)

timelineIndexPropertiesMap.put("timestamp", ValueContext.numeric(12345678L);

The method to access the timelineindex values would be same.