Distance and Geospatial Boosting

17 views
Skip to first unread message

Dieder Timmerman

unread,
Aug 21, 2017, 8:16:50 AM8/21/17
to RavenDB - 2nd generation document database

Hi,

I have a question about spacial possibilities. I can get scored results by a given spatial radius. That means that someone that is closer to my given geo-location will have an higher rank in the result list. I have however other searchterm conditions in my query too and given some of them a boost. Is it possible to boost the spatial search too and how do I do this in C#? Can I also return the distances from the given location?

I can query for a given spatial radius. 
eg.   query = query.WithinRadiusOf(spatialFieldname, distance, (double)lat, (double)lon);

When I declare this in the index
public class MyIndex : AbstractIndexCreationTask<ResultClass>
    {
        public MyIndex()
        {
            Map = ResultClass => from result in ResultClass
                                select new
                                {
                                    Id ,                                  
                                    Coordinates = SpatialGenerate("Coordinates", Convert.ToDouble(Latitude), Convert.ToDouble(Longitude) )

                                };

But how can I boost?
How can I report the user the distances? For example I wanna know the distance of the nearest supermarkets near my house.

Thanks in advance.

Oren Eini (Ayende Rahien)

unread,
Aug 21, 2017, 9:32:31 AM8/21/17
to ravendb
You can explicitly specify sort order for a query using spatial. In that case, you can sort by a property and then by distance (OrderByDistance())

The distances aren't exposed, but since you have the actual data in the results, you can compute that client side.

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages