2015-12-12 107 views
0

我使用批量插入方法創建neo4j圖形數據庫。加載DBpedia數據集並構建它的屬性圖。Neo4j索引不起作用

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,但我敢肯定,數據庫包含與resourceName資源。我應該如何在這裏使用索引進行查詢?

回答

1

您是否真的將節點添加到索引?例如:

index.add(node,properties) 

您是否在批次插入過程中查詢?如果是這樣,刷新指數

index.flush(); 

使新索引節點查詢可見。建議您不要經常這樣做,請參閱http://neo4j.com/docs/stable/indexing-batchinsert.html

+0

我做了他們兩個。不幸的是,結果是一樣的。 –