1
是否可以使用自動索引功能在Neo4J上導入數據?我試圖導入使用BatchInserter和BatchInserterIndex類似於下面的示例數據:Neo4J:批量執行自動索引
BatchInserter inserter = BatchInserters.inserter("/home/fmagalhaes/Neo4JDatabase");
BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);
BatchInserterIndex nodeIndex = indexProvider.nodeIndex("node_auto_index", MapUtil.stringMap("type","exact"));
BatchInserterIndex relIndex = indexProvider.relationshipIndex("relationship_auto_index", MapUtil.stringMap("type","exact"));
...
inserter.createNode(vertexId, properties);
nodeIndex.add(vertexId, properties);
...
的問題是,當完成批量處理,我想通過以下操作來打開這個數據庫藍圖通用API:
Graph g = new Neo4jGraph("/home/fmagalhaes/Neo4JDatabase");
Set<String> nodeIndices = ((KeyIndexableGraph)g).getIndexedKeys(Vertex.class);
Set<String> relIndices = ((KeyIndexableGraph)g).getIndexedKeys(Edge.class);
並且nodeIndices和relIndices都是空的。當我在Blueprints API上打開圖形數據庫時,自動索引功能被禁用。是否可以在批處理過程中創建一個自動索引,以便在使用Blueprints API打開數據庫時,該索引將可見(並且將繼續索引數據,因爲屬性會添加到頂點和邊)。
1.我中省略上面的例子,但我在索引相同的屬性關閉IndexProvider和BatchInserter。 2.正確。事實上,我正在測試Blueprints和Neo4J,我使用的唯一屬性是:「__id」。我想索引這個屬性,因爲我想使用來自Blueprints API的IdGraph包裝。 3.如何在嵌入式Neo4j數據庫上啓用自動索引?打開數據庫時,我應該使用node_auto_indexing = true和relationship_auto_indexing = true配置嗎? –
此外,當我僅使用Blueprints API(和Neo4jGraph類實現)導入我的數據而不是使用BatchInserts時,當我使用createKeyIndex()方法時,我能夠在以後直接打開數據庫而無需設置node_auto_indexing = true和relationship_auto_indexing = true。不知何故,這種配置嵌入數據庫本身。使用BathInserts時,是否可以在數據庫中嵌入此auto_index行爲,而不必在打開數據庫時在配置上手動設置它們? –