如何为OrientDB(2.2.x)的空间模块创建索引?

How to create index for spatial module for OrientDB (2.2.x)?

OrientDB 已从 2.2 升级到空间模块功能。

什么是 Java 相当于为此创建索引:

CREATE INDEX ON (geometry-field) SPATIAL ENGINE LUCENE

例如:

ODocument location = new ODocument("OPoint");
location.field("coordinates", Arrays.asList(12.4684635, 41.8914114));

ODocument doc = new ODocument("Restaurant");
doc.field("name","Dar Poeta");
doc.field("location",location);

doc.save();

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

(我在这里看到了一些代码:[http://orientdb.com/docs/2.1/Spatial-Index.html] 但似乎这是针对以前的版本 "spatial index",而不是从 2.2 开始的 "spatial module"。)

您可以通过 Java:

使用 OSQL 创建索引
    db.command(new OCommandSQL("CREATE INDEX Restaurant.location ON Restaurant(location) SPATIAL ENGINE LUCENE")).execute();