8

如何使用 NEST应用地理距离范围过滤器?好像是这样的

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

但是我如何传递目标位置的长/纬度?

(类似的问题已被问到Java 客户端)

4

1 回答 1

7

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.

于 2013-04-19T20:24:49.543 回答