Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j批插入器在重新启动时初始化数据库_Neo4j_Spring Data Neo4j - Fatal编程技术网

Neo4j批插入器在重新启动时初始化数据库

Neo4j批插入器在重新启动时初始化数据库,neo4j,spring-data-neo4j,Neo4j,Spring Data Neo4j,我使用Neo4j批插入器在数据库中插入节点。我使用LuceneBatchInserterIndexProvider作为索引。我有多个导入数据的文件。我希望如果我的进程中断,那么我应该能够从下一个文件重新启动进程。但每当我重新启动这个进程时,它就会在graph文件夹中创建新的db和新的索引。我的初始化代码如下所示 Map<String, String> config = new HashMap<String, String>(); config.put("neostore.

我使用Neo4j批插入器在数据库中插入节点。我使用LuceneBatchInserterIndexProvider作为索引。我有多个导入数据的文件。我希望如果我的进程中断,那么我应该能够从下一个文件重新启动进程。但每当我重新启动这个进程时,它就会在graph文件夹中创建新的db和新的索引。我的初始化代码如下所示

Map<String, String> config = new HashMap<String, String>();
config.put("neostore.nodestore.db.mapped_memory", "2G");
config.put("batch_import.keep_db", "true");
BatchInserter db = BatchInserters.inserter("ttl.db", config);
BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(
                    db);
index = indexProvider.nodeIndex("ttlIndex",
                    MapUtil.stringMap("type", "exact"));
index.setCacheCapacity(URI_PROPERTY, indexCache + 1);
Map config=newhashmap();
config.put(“neostore.nodestore.db.mapped_memory”,“2G”);
config.put(“batch_import.keep_db”,“true”);
BatchInserter db=BatchInserters.inserter(“ttl.db”,config);
BatchInserterIndexProvider indexProvider=新LuceneBatchInserterIndexProvider(
db);
index=indexProvider.nodeIndex(“ttlIndex”,
stringMap(“类型”、“精确”);
setCacheCapacity(URI_属性,indexCache+1);
有人能帮忙吗

提供更多细节。我有多个文件(大约400个)要导入Neo4j。 我想把我的过程分成几批。每次批处理后,我都要重新启动流程。 我使用了neo4j批处理插入器配置batch_import.keep_db=“true”。这不会清除图形,但重新启动后,indexer已丢失信息。我有这个方法来检查节点是否存在。我确信在重新启动之前我已经创建了节点

private Long getNode(String nodeUrl)
    {
        IndexHits<Long> hits = index.get(URI_PROPERTY, nodeUrl);
        if (hits.hasNext()) { // node exists
          return hits.next();
        }
        return null;
    }
private Long getNode(字符串nodeUrl)
{
IndexHits hits=index.get(URI_属性,nodeUrl);
如果(hits.hasNext()){//节点存在
返回hits.next();
}
返回null;
}

这听起来可能有点傻,但在创建插入器之前,请检查确保没有删除数据库文件夹内容的代码。据我所知,批插入器不会创建新数据库。它继续使用现有的数据库。对于前一段时间的索引,有一个问题是,如果在插入运行期间没有写入索引,那么索引将被删除。“但看来这已经解决了。”迈克尔,你说得对。。我没有关闭我的indexprovider<代码>BatchInserterIndexProvider indexProvider=新LuceneBatchInserterIndexProvider(db);BatchInserterIndex nodeIndex=indexProvider.nodeIndex(“ttlIndex”,MapUtil.stringMap(“type”,“exact”);nodeIndex.setCacheCapacity(URI_属性,500000+1)###在我执行此操作之前,nodeIndex.flush()###我没有执行indexProvider.shutDown()而是定期刷新节点索引,但从未关闭indexProvider。如果我关闭indexprovider并重新启动进程。我能够从节点索引查询节点。