2014-10-30 36 views
0

由於在定義的半徑距離中的地理位置,我們需要定位一組對象。Neo4j空間問題:findWithinDistance:ava.lang.IllegalArgumentException:具有相同名稱但存在不同配置的索引

我們嘗試使用SpatialRepository類實現方法「findWithinDistance」

波紋管用於與指數型點implemntation存儲對象的經度和緯度所使用的代碼中使用Neo4Ĵ空間庫:

@NodeEntity 
@TypeAlias(value="MyObject") 
public class MyObject{ 


    @GraphId Long nodeId; 
    private String label; 
    private String description; 
    private Double lat; 
    private Double lon; 

    @Indexed(indexType = IndexType.POINT, indexName = "locations") 
    String wkt; 

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

1)第一次運行,我們沒有任何問題創造的Neo4j數據庫(我們可以看到,在Neo4j的正確的數據對象) 對象爲第二次運行或新對象的創建我們已經說過:具有相同名稱但存在不同配置的索引!

java.lang.IllegalArgumentException: Index with the same name but different config exists! 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectRepositoryImpl': Injection of autowired dependencies failed; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Could not autowire field: org.springframework.data.neo4j.support.Neo4jTemplate fr.spart.is.neo4j.repository.ObjectRepositoryImpl.template; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'neo4jTemplate' 
defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; 
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() 
throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: 
Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Index with the same name but different config exists! 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) 

的另一點,我必須實現findWithinDistance方法:我們應該使模板方法或Neo4j的Cypher支架查詢來搜索對象?

感謝你的幫助,

,如果你需要精度

+0

這是您的使用空間索引唯一一類?你是否總是設置indexName值? Neo4J是嵌入式還是針對遠程服務器運行,並且是否包含/安裝了空間庫? – JohnMark13 2014-10-31 12:11:15

回答

0

你怎麼跑這不要猶豫?

您是否可能首先運行「純查詢」變體,導致索引被創建爲lucene索引而不是空間索引?

您也可以刪除與Neo4j的模板索引(你可能要註釋掉該修復程序運行註釋)

相關問題