【问题标题】:Neo4j BatchInserter and TimelineIndex [v1.9.4]Neo4j BatchInserter 和 TimelineIndex [v1.9.4]
【发布时间】:2014-01-06 12:12:57
【问题描述】:

我正在使用 BatchInserterIndex 将大量数据摄取到 Neo4j DB。我打算在批处理期间将节点添加到 TimelineIndex (Lucene)。现在,以正常方式,TimelineIndex 需要 (node, long) 来添加索引。它可能在内部使用密钥“时间戳”。 (在 github 中的 LuceneTimeline.java 中检查)

我的问题是我能够将节点插入到 TL 索引中,但无法使用常规 java API 检索它们。它总是将timelineIndex.getFirst() 返回为null。 我已将索引初始化如下。

常规访问方式

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

批量提取

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)

现在,当我尝试使用timelineIndex.getFirst() 来检索Batch Inserter 添加的数据时,它总是返回null。 但是,在 SAME DB 上以常规方式添加的节点会返回正确的值。

我哪里错了?

【问题讨论】:

    标签: neo4j batch-insert


    【解决方案1】:

    在插入时间线索引的 BatchInserterIndex 方法中,键为“时间戳”,值应为数值类型的 ValueContext 实例。 所以,你需要调用静态函数 ValueContext.numeric(value)

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

    访问时间线索引值的方法是相同的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-11
      • 1970-01-01
      相关资源
      最近更新 更多