MongoDB geonear和文本命令驱动程序2.0

文本查询,q作为查询字符串:

coll.FindAsync<Foo>(Builders<Foo>.Filter.Text(q));

文本查询需要一个文本索引。要从C#创建代码,

coll.Indexes.CreateOneAsync(Builders<Foo>.IndexKeys.Text(p => p.Message));

附近查询:

coll.FindAsync<Foo>(Builders<Foo>.Filter.Near(p => p.Location, x, y, maxDis, minDis));
coll.FindAsync<Foo>(Builders<Foo>.Filter.Near(p => p.Location, 5, 5, 100, 0));

同样,这些需要索引:

coll.Indexes.CreateOneAsync(Builders<Foo>.IndexKeys.Geo2D(p => p.Location));

 

posted @ 2020-02-08 20:16  许宝  阅读(314)  评论(0编辑  收藏  举报