I'm having some trouble generating a SpatialIndex.
I want to get the closest event from a given location.
When I query my Coordinates has the value IgnoredLuceueField I think they mean LuceneField but it says Luceue so it's not a typo from me.
I have the folowing index
public class ClosestEvent : AbstractIndexCreationTask<Event,ClosestEvent.ReduceResult>
{
public ClosestEvent()
{
Map = events=> from myEvent in events
select new
{
Id = myEvent .Id.ToString(),
Coordinates = SpatialGenerate("Coordinates",myEvent.eventLocation.Latitude, myEvent.eventLocation.Longitude)
};
Reduce = results => from result in results
group result by result.Id
into g
select new ReduceResult
{
Coordinates = g.Select(x=>x.Coordinates).First(),
Id = g.Key
};
}
public class ReduceResult
{
public string Id { get; set; }
public object Coordinates { get; set; }
}
}
And I have the following query for this:
public ClosestEvent.ReduceResult GetClosestEvent(GeolocationFilter filter)
{
using (var session = Store.OpenSession())
{
var query = session.Query<ClosestEvent.ReduceResult, ClosestEvent>().Customize(x => x.SortByDistance(
lat: filter.lat,
lng: filter.lng,
fieldName: "Coordinates"
)).Take(1).ToList();
return query.First();
}
}
This returns:
Id : a Guid as string
Coordinates: "IgnoredLuceueField"
Additional information: my database is hosted by ravenHQ