birikino
birikino

Reputation: 71

How do I add to a spatial index in OrientDB?

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?

Upvotes: 2

Views: 679

Answers (1)

wolf4ood
wolf4ood

Reputation: 1949

Try to specify max distance with syntax

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

Upvotes: 1

Related Questions