Query.Spatial weirdness

25 views
Skip to first unread message

Johannes Rudolph

unread,
Jun 1, 2015, 9:53:07 AM6/1/15
to rav...@googlegroups.com
I'm working with a spatial index and have been hit by this weird behavior of the Api (2.5). At best, it's a documentation/api design bug. 


What it boils down to is that a spatial index query with query.Spatial(...) returns no results while an equivalent query works with query.Customize( x => x...) works.
Why am I seeing this behavior? What is the .Spatial method on RavenQueryable supposed to do? It doesn't have xml docs on it either.

var linqQueryWithSpatial = Session.Query<ClassWithLocation, NamedSpatialFieldIndex>()
.Spatial( x => x.Location, x => x.WithinRadiusOf( 1.0, 10.0, 11.0 ) )
.Customize( x => x.WaitForNonStaleResults() )
.ToList();
 
Assert.Empty( linqQueryWithSpatial ); // for some reason this doesn't work
 
var linqQueryWithCustomize = Session.Query<ClassWithLocation, NamedSpatialFieldIndex>()
.Customize( x => x.WithinRadiusOf( "Location", 1.0, 10.0, 11.0 ) )
.Customize( x => x.WaitForNonStaleResults() )
.ToList();
 
Assert.Single( linqQueryWithCustomize ); // this works


Oren Eini (Ayende Rahien)

unread,
Jun 2, 2015, 7:11:04 AM6/2/15
to ravendb

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paweł Pekról

unread,
Jun 8, 2015, 8:31:10 AM6/8/15
to rav...@googlegroups.com
Hi Johannes,

the actual problem lies in the order of parameters of this method:
.Spatial( x => x.Location, x => x.WithinRadiusOf( 1.0, 10.0, 11.0 ) )

they are: radius, x, y
which translates to radius, longitude, latitude

since this is inconsistent with the rest of the API, we marked this method as obsolete (with proper message) and introduced 'WithinRadius' where parameter names (and their order) are consistent to avoid future confusion.


With regards,
P.
Reply all
Reply to author
Forward
0 new messages