0
我正在尝试通过Java API创建空间索引,我正在使用Orient DB orientdb-enterprise-2.2.21。 使用远程连接运行测试。我试图用几种方法创建类和属性已经创建。使用orientdb-enterprise-2.2.21和orientdb-community-2.2.21的空间索引问题
nodeClass = graph.createVertexType(NODE_CLASS_NAME);
nodeClass.createProperty("latitude", OType.DOUBLE);
nodeClass.createProperty("longitude", OType.DOUBLE);
nodeClass.createProperty("name", OType.STRING);
nodeClass.createProperty("color", OType.STRING);
nodeClass.createProperty("location", OType.EMBEDDED);
,结果是:
我在几个方面创造了空间索引,他们都失败:
案例1中的 “老办法”:
nodeClass.createIndex("Group.latitude_longitude", "SPATIAL", null, null, "LUCENE", new String[] { "latitude", "longitude" });
结果:
Exception in thread "main" com.orientechnologies.orient.core.index.OIndexException: Index with type SPATIAL and algorithm null does not exist.
DB name="demodb"
情况2:
graph.command(new OCommandSQL(
"CREATE INDEX Group.location ON Group(location) SPATIAL ENGINE LUCENE")).execute();
结果:
Exception in thread "main" com.orientechnologies.orient.core.index.OIndexException: Index with type SPATIAL and algorithm null does not exist.
DB name="demodb"
情况3:
OIndex<?> idx = nodeClass.getProperty("location").
createIndex(OClass.INDEX_TYPE.SPATIAL, new ODocument().field("ignoreNullValues", true));
结果:
Exception in thread "main" com.orientechnologies.orient.core.index.OIndexException: Index with type SPATIAL and algorithm null does not exist.
DB name="demodb"
POM:
<orientdb.version>2.2.21</orientdb.version>
<tinkerpop.version>2.6.0</tinkerpop.version>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-graphdb</artifactId>
<version>${orientdb.version}</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-spatial</artifactId>
<version>${orientdb.version}</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-lucene</artifactId>
<version>${orientdb.version}</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
有没有人有任何建议?遇到与orientdb-community-2.2.21相同的行为。
感谢您的反馈帮助。但是,我必须使用嵌入式SQL创建属性和索引才能正常工作。这是它工作的唯一方式:OCommandRequest commandRequest = graph.command(新的OCommandSQL(“CREATE INDEX Group.location ON ON Group(location)SPATIAL ENGINE LUCENE”)); – zambra33
要清楚我首先需要 - >(1)graph.command(新的OCommandSQL(“CREATE PROPERTY Group.location EMBEDDED OPoint”))。execute();然后 - >(2)OCommandRequest commandRequest = graph.command(新的OCommandSQL(“CREATE INDEX Group.location ON ON Group(location)SPATIAL ENGINE LUCENE”));看起来有点尴尬,必须从Java做到这一点。欣赏信息。 – zambra33