2014-02-13 35 views
0

我試圖通過批量填充WKT節點。通過批量添加時未創建空間索引

空間索引名稱是'Geocode',批處理創建lucene索引'Geocode-neo4j_spatial .....'當我對'Geocode'索引執行'withinDistance'密碼時,我得到'Index not存在'錯誤。

有人能幫我什麼是我的代碼下面缺少/錯誤?

IndexImplementation indexImpl = new SpatialIndexImplementation(graphService); 
//Creating Index. I see that the associated lucene index is getting created 
Index<Node nodeIndex = indexImpl.nodeIndex("Geocode", SpatialIndexProvider.SIMPLE_WKT_CONFIG); 

    Label label = DynamicLabel.label("Address"); 
    GlobalGraphOperations global = GlobalGraphOperations.at(graphService); 

    Iterable<Node allNodes = global.getAllNodesWithLabel(label); 
    for(Node node: allNodes){ 
     if(node.hasProperty("addressLine1")){ 
    //Adding to the Spatial Index. I see that LayerNodeIndex.add method is called 
      nodeIndex.add(node, "addressLine1", 
    node.getProperty("addressLine1")); 
    } 
+0

我通過SDN添加節點(正確創建索引),然後使用批量插入來加載其餘節點,從而實現了這一目標。不過,在上面的代碼中找到錯誤將會很有幫助。 – patb23

+0

您提供給索引的鍵/值只要使用配置的屬性(在您的案例中爲'wkt')就沒有關係了。它不應該爲Geocode創建lucene索引,而應該創建一個圖表空間索引。 –

回答

0

我認爲你的索引創建是錯誤的。

應該僅僅是:

gdb.index().forNodes("GeoCode",SpatialIndexProvider.SIMPLE_WKT_CONFIG); 

所有IMPL東西應該發生在服務器端。