【问题标题】:Numeric index during batch insertion in Neo4jNeo4j中批量插入期间的数字索引
【发布时间】:2011-10-22 09:04:41
【问题描述】:

我正在将节点和关系批量插入到 Neo4j 图形数据库中。一切正常,包括多个属性的索引([String] name, [int] id)。但是,当我尝试按范围查询属性“id”的索引时,它不会返回任何结果。

问题是,正如我从 the non-batch example 得出的那样,我不能像这样将数字 ValueContext 提供给 BatchInserterIndex

Map<String, Object> properties = new HashMap<String, Object>(2);

properties.put("name", urs.getString(1));

// I can do this:
properties.put("id", urs.getInt(2));

// But not this (throws an "invalid type" exception):
// properties.put("id", new ValueContext( urs.getInt(2) ).indexNumeric());

long node_id = inserter.createNode(properties);
index.add(node_id, properties);

在批量插入期间我没有找到任何关于数字索引的documentation

查询代码如下:

IndexManager index = gdb.index();
Index<Node> people = index.forNodes("people");
IndexHits<Node> hits = people.query(
    QueryContext.numericRange("id", min_id, max_id)
  );

是否可以在批量插入操作中添加数字索引,以便我可以按范围查询值?

谢谢。


编辑

我做错了什么是我试图将相同的属性映射传递给createNode()index.add()。前者崩溃了,因为它不需要ValueContext 并且不理解它。因此,请务必将不同的属性映射传递给这些方法,并将 ValueContext-ed 数值包含在用于 index.add 的值中:

Long value = 1L;

long node_id = inserter.createNode(
  MapUtil.map("id", value, "other_prop", other_value));

index.add(node_id,
  MapUtil.map("id", ValueContext.numeric( value ), "other_prop", other_value));

【问题讨论】:

    标签: java indexing numeric neo4j batch-insert


    【解决方案1】:

    您使用的是哪个版本的 neo4j?它在最新版本中运行

    【讨论】:

    • 版本是neo4j-community-1.4.1,是最新的。您确定通过使用 batch 插入索引获得范围结果吗?如果是这样,你能更具体一点吗?您是否设法将ValueContext 传递给批处理插入器索引?
    • 能不能看一下测试:github.com/neo4j/community/blob/master/lucene-index/src/test/…,好像很像,通过了。
    • 是的,确实如此。我将在帖子中附加我的错误描述。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2011-10-20
    • 2017-06-05
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 2016-09-26
    • 2013-12-10
    相关资源
    最近更新 更多