本文介绍了如何在OrientDB中添加空间索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Studio的OrientDB 2.0.我使用文档中的代码成功创建了Lucene空间索引:

I'm using OrientDB 2.0 from the studio. I created a Lucene spatial index successfully, using the code from the documentation:

CREATE class Place extends V

CREATE property Place.name string

CREATE property Place.latitude double

CREATE property Place.longitude double

CREATE INDEX Place.l_lon ON Place(latitude,longitude) SPATIAL ENGINE LUCENE

然后我用latitudelongitude创建了一些Place对象.

I then created some Place objects with latitude and longitude.

当我尝试使用记录的格式进行空间搜索

When I attempt to do a spatial search using the documented format

select from Class where [<lat-field>,<long-field>] NEAR [<x>,<y>]

即使我输入了Place个对象之一的精确坐标,搜索也不会出错,但不会返回任何结果.

the search completes without error but returns no results, even when I pass in the exact coordinates of one of the Place objects.

我也尝试过直接使用

select from index:Place.l_lon

也成功但没有错误,但未返回任何结果.我在想我的索引可能为空.我尝试从架构编辑器重建它,但仍然没有结果.而且,据我所知,无法手动将诸如位置坐标之类的复合条目添加到索引中.我想念什么吗?

which also succeeded without error but returned no results. I'm thinking that my index may be empty. I tried rebuilding it from the schema editor but still no result. Also, as far as I can tell, there's no way to manually add composite entries like location coordinates to an index. Am I missing something?

推荐答案

尝试使用语法指定最大距离

Try to specify max distance with syntax

select  from Class where [<lat-field>,<long-field>,$spatial] NEAR [<x>,<y>,{"maxDistance": distance}]

这篇关于如何在OrientDB中添加空间索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 04:25