【问题标题】:Neo4j indexing doesn't workNeo4j 索引不起作用
【发布时间】:2015-12-12 14:45:35
【问题描述】:

我正在使用批量插入方法来创建 neo4j 图形数据库。加载 DBpedia 数据集并构建它的属性图。

public Neo4jBatchHandler(BatchInserter db2, int indexCache, int timeout) {
    this.db = db2;
    this.indexCache = indexCache;
    this.timeout = timeout;

    BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(
            db);
    index = indexProvider.nodeIndex("ttlIndex",
            MapUtil.stringMap("type", "exact"));
    index.setCacheCapacity("__URI__", indexCache + 1);

}

这是我用于索引的代码。


在查询操作期间,我想使用索引来提高效率。但不幸的是,它不起作用。这是我的代码:

    IndexHits<Long> hits = index.get("__URI__",
                    resourceName);

它返回 null,但我确定 db 包含带有 resourceName 的资源。我应该如何在这里使用索引进行查询?

【问题讨论】:

    标签: neo4j lucene batch-insert


    【解决方案1】:

    您是否真的将节点添加到索引中?例如:

    index.add(node,properties)
    

    您是否在批量插入过程中进行查询?如果是,刷新索引

    index.flush();
    

    这样新索引的节点对于查询是可见的。建议不要经常这样做,见http://neo4j.com/docs/stable/indexing-batchinsert.html

    【讨论】:

    • 我都做了。不幸的是,结果是一样的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-09
    相关资源
    最近更新 更多