0

I am trying to populate WKT nodes through Batch.

The spatial index name is 'Geocode' and the batch creates the lucene index 'Geocode-neo4j_spatial.....' When I execute the 'withinDistance' cypher against the 'Geocode' index, I get 'Index does not exist' error.

Could someone help me what is missing/wrong in my code below?

    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"));
     }
patb23
  • 387
  • 5
  • 21
  • I got this working by adding a node through SDN (that creates the index correctly) and then used Batch insert to load the remaining nodes. Still, would be helpful to find what is wrong in the above code. – patb23 Feb 14 '14 at 18:25
  • It doesn't matter which key/value you provide to the index it just uses the configured property (in your case `wkt`) And it shouldn't create a lucene index per se for Geocode but an in-graph spatial index. – Michael Hunger Feb 16 '14 at 14:22

1 Answers1

0

I think your index creation is wrong.

It should just be:

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

All the impl stuff should happen on the server side.

Michael Hunger
  • 41,339
  • 3
  • 57
  • 80