How do I add to a spatial index in OrientDB?

2019-07-18 01:27发布

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条回答
The star\"
2楼-- · 2019-07-18 02:21

Try to specify max distance with syntax

select  from Class where [<lat-field>,<long-field>,$spatial] NEAR [<x>,<y>,{"maxDistance": distance}]
查看更多
登录 后发表回答