Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geo distance range filter in NEST?

How can I apply a geo distance range filter using NEST? It seems to be something like

var results = client.Search<MyDataType>(s => s
.Filter(m => m.GeoDistance(c => c.Location, f => f.Distance(100, GeoUnit.mi)));

but how do I pass in long/lat of the target location?

(similar question has been asked for Java client)

like image 729
Max Avatar asked Apr 19 '13 16:04

Max


1 Answers

Answering my own question. This works:

var results = client.Search<MyDataType>(s => s
.Filter(m => m.GeoDistance(
  c => c.Location, 
  f => f.Distance("100 mi").Location(40.7, -74.0)));

After some debugging, I suspect that f.Distance(100, GeoUnit.mi) didn't work due to a bug in NEST.

like image 93
Max Avatar answered Sep 17 '22 19:09

Max