How do I add to a spatial index in OrientDB?

点点圈 提交于 2019-12-12 17:22:39

问题


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

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>]

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

I also tried querying the index directly using

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?


回答1:


Try to specify max distance with syntax

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


来源:https://stackoverflow.com/questions/28137648/how-do-i-add-to-a-spatial-index-in-orientdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!