Spatial noob exception "Index with the same name but different config exists!"

Showing 1-19 of 19 messages
Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/21/12 1:54 PM
Hi All,

I'm to get some Spatial basics under my belt but after fiddling around with spatial all afternoon I'm stuck at what seems like the most trivial of problems. ( I actually ran into this same problem in previous attempts and ended up abandoning my efforts )

I'm using the spatial example in the Good Relationships manual and Michael's post as a starting point. I'm using venues from New York City but when I run a unit test, I get an "Index with the same name but different config exists!" exception. I suppose that this has something to do with points needing to be unique and receiving the same wkt value if they're close together. But it seems like that should be something expected from real life, for example, you can have multiple "venues" in an office block.

Is there something obvious I'm missing here???

As always, thank you in advance!

As an FYI, I'm using the following Venue class and I tried defining the wkt as both %.2f and %s, which I've also seen used.

@NodeEntity
public class Venue {
@GraphId private Long graphId;
@Indexed(indexType = IndexType.POINT, indexName = "VenueLocation")
private String wkt;

public void setLocation(float lon, float lat) {
this.wkt = String.format("POINT( %.2f %.2f )",lon,lat);
}

}

public interface VenueRepository extends GraphRepository<Venue>, SpatialRepository<Venue>{}


And for the unit test I'm just doing this: 

@Autowired private VenueRepository venueRep;


@Test
public void test2FiveNodes(){
for (int i = 0; i < vArray.length; i++) {
Venue venue = new Venue();
venue.setLocation(locArray[i][1], locArray[i][0]);
venue = venueRep.save(venue);
}
}



Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Peter Neubauer 9/21/12 2:00 PM
Michael,
are all the tests failing like this or might there be an issue with
the database not being totally clean before runs?

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to @graphconnect.
> --
>
>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/21/12 3:08 PM
I should have mentioned, I clean the database before every test like so:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:testContext.xml")
@Transactional
public class SpatialTest {

@Rollback(false)
@BeforeTransaction
public void cleanUpGraph() {
Neo4jHelper.cleanDb(template);
}


Also I just tried deleting the whole database and running just this test and I get the error exactly when the second node is saved.

@Test
public void testNodes(){
for (int i = 0; i < vArray.length; i++) {
Venue venue = new Venue();
venue.setLocation(locArray[i][1], locArray[i][0]);
System.out.println(i+": "+venue.getLocation());
venue = template.save(venue);
}
Set<Venue> nodes = (Set<Venue>) venueRep.findAll();
assertEquals(nodes.size(),5);
}



Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Peter Neubauer 9/21/12 3:14 PM
What is Neo4jHelper.cleanDb(template); doing?

Do you have that test isolated standalone somewhere? We might be able
to recreate it and add it to the standard SDN tests ...

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to @graphconnect.


On Fri, Sep 21, 2012 at 3:08 PM, Michael Janiak
> --
>
>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/21/12 3:32 PM
Hi Peter, thank you for these rapid responses!

I use the Neo4jHelper to clean the database before each test. I've been using it for all my other tests and it's been working so far.

Here's all the pertinent code: http://pastebin.com/DR1B9mu9
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Lasse Westh-Nielsen 9/24/12 1:26 AM
Michael,

The code you shared seems to work, for me at least - I have put it into a single file test here, using just an in-memory db:


Interestingly, when I add the cleanup bit I get a problem with Node[0], not sure why - but don't think it has to do with spatial necessarily.



--
 
 

Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Craig Taverner 9/24/12 9:12 AM
Going back to the first email, I noticed that the error message was "Index with the same name but different config exists!". I should mention that this has nothing to do with features being similar or identical. It is about the definition of the layer. Since we allow the layers to have custom code for mapping custom domain models into geometries, this knowledge is embedded in the layer in a dynamic way. For example, we provide three built-in types of layers, OSMLayer, SimplePointLayer and EditableLayerImpl (for WKT). If you try to create two layers with the same name, but different types, you will get the error you see above.

I must assume that you have code that tries to create the layer a second time, and the second time it does not specify the layer type and gets the default choice (probably EditableLayerImpl). But the first time it was created with some other type, perhaps SimplePointLayer if you are storing only simple lat/long locations (seems to be the case).


--
 
 

Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/25/12 6:53 AM
Hi Lasse, thank you for doing that!

I'm trying to reproduce your results using your exact code including the ImpermanentGraphDatabasehowever I get a java.lang.NoClassDefFoundError: org/springframework/core/annotation/AnnotationAttributes

This feels like a pom problem. Are there other dependencies I should be using?

I've got

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>


<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.1.0.RC2</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.0.RELEASE</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency> 
<groupId>org.neo4j</groupId> 
<artifactId>neo4j-kernel</artifactId> 
<type>test-jar</type>
<version>1.8.M06</version>
<scope>test</scope> 
</dependency> 

<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>

Michael
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/25/12 6:59 AM
Hi Chris, sorry but that is way over my head. At the moment I'm literally having a problem with executing the code I pasted earlier  http://pastebin.com/DR1B9mu9. I initially thought there was a problem with having multiple nodes of a similar POINT index but you seem to be saying that that is not the case. Are you saying that I'm inadvertently creating two layers of the same name? How could I change the above code to correct that?

Could it be something to do with the fact that I use a REST database for my test context?

<neo4j:config graphDatabaseService="graphDatabaseService"/>
<bean id="graphDatabaseService" 
class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
 <constructor-arg index="0" value="http://localhost:7474/db/data" />
</bean>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Hunger 9/25/12 8:45 AM
Can you share the full exception stacktrace?

And could you upgrade to SDN-rest 2.1.0.RC4 ?

And remove the explicit rest-graphdb dependency ?

I think there was an issue with index type-checking in the rest-graphdb but am not sure.

A sample project would be great though !

Michael

--
 
 

Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/25/12 6:41 PM
Hi Michael,

I updated the SDN rest dependency and tried removing the rest-grapdb dependency but it still doesn't work.

Here's the full stack trace and test project:  https://github.com/MichaelJaniak/neo4j-spatial-test/. I've included all the dependencies that I'm using for my main project.

As an aside, removing the dependency artifactId: spring-data-neo4j-rest produces one of these: ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3db9b677] to prepare test instance [com.spatialtest.app.SpatialTest@6b7a5e49] java.lang.IllegalStateException: Failed to load ApplicationContext 


Michael
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Peter Neubauer 9/26/12 12:14 AM
Michael,
are you sure you have installed the spatial plugin into your Neo4j
server? Otherwise the spatial index will not work.

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to @graphconnect.


On Tue, Sep 25, 2012 at 6:41 PM, Michael Janiak
> --
>
>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 9/26/12 6:05 AM
Peter,

Thank you! 

That's why it's noob question, I didn't install the plugin I thought the maven dependency below would be enough.

I'll try it out. Hopefully I'll figure out how to get it onto Heroku.

<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>

Best,

Michael
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Peter Neubauer 9/26/12 7:36 AM
Michael,
you have to install the plugin into your server that you are running
against over REST in your setup, see

https://github.com/neo4j/spatial/

"Using the Neo4j Spatial Server plugin"

bascially,
build the plugin with


git clone https://github.com/neo4j/spatial/

then copy the target/....server-plugin.zip and expand it unde rthe
NEO4J_SERVER/plugins directory.

Cheers,

/peter neubauer

Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to @graphconnect.


> --
>
>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 10/2/12 10:53 AM
Thanks Peter, I have this, running on my local Neo4j server and with a few hiccups it seems to be working, for example, I can run search queries like this, which is great:

START venuesSpatial=node:location('withinDistance:[40.7143, -74.0099, 15.0]'),
user = node(5)
MATCH user-[:LIKES]->venues
WHERE ID(venues) = venuesSpatial.id AND venues.name=~".*(?i)hall.*"
RETURN venues

My last question is, I have my production app running on Heroku and I'm using a Neo4j hosted database instance. How do I go about adding the spatial plugin onto that? I've had a look at this documentation and it I can't find any guidance https://devcenter.heroku.com/articles/neo4j

Michael
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Peter Neubauer 10/2/12 12:33 PM
Michael,
uhh, first, I am not sure Heroku instances should be run in production
(isn't it in beta)? Secondly, currently the free plan (paid ones to
come) is not letting you install plugins. for that, I would take an
environment where you have more control, like an AWS instance on US
East (near Heroku), and spin up your own Neo4j Server, that you can
connect to from Heroku. Would that work?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to http://graphconnect.com
> --
>
>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 10/3/12 7:22 AM
I thought it would be something like that. We were trying to push that out into the future but I guess we'll have to fast track. We'll probably just deploy the whole app onto EC2. I saw that someone prepared an AMI Neo4j image so we might use that, or just roll our own if it's too complicated.

Michael
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Peter Neubauer 10/3/12 8:08 AM
Yeah,

here you go, http://cloud.dzone.com/articles/how-deploy-neo4j-instance

feel free to publish your updated instance for others to use.

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to http://graphconnect.com


> --
>
>
Re: [Neo4j] Spatial noob exception "Index with the same name but different config exists!" Michael Janiak 10/20/12 10:18 AM
Thank you so much for all your help!

We've actually decided against this for now... too much effort for a beta, so we're taking the mvp approach and living without.