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