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

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

coll.FindAsync(Builders.Filter.Text(q));

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

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

附近查询:

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

同样,这些需要索引:

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

 

你可能感兴趣的:(MongoDB geonear和文本命令驱动程序2.0)