使用orientdb-enterprise-2.2.21和orientdb-community-2.2.21的空间索引问题

时间:2017-06-16 03:58:33

标签: orientdb orientdb2.2

我正在尝试通过Java API创建空间索引我正在使用Orient DB orientdb-enterprise-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遇到了相同的行为。

1 个答案:

答案 0 :(得分:0)

您是否在服务器上安装了空间插件?

http://orientdb.com/docs/2.2/Spatial-Index.html