【发布时间】:2021-01-17 20:36:22
【问题描述】:
帮助了解 RavenDB 查询,我正在使用以下模型来存储和索引空间数据。
public class GeoRecord {
public string SearchId {get; set;}
public string Tag {get; set;}
public double Latitude {get; set;}
public double Longitude {get; set;}
}
public class GeoRecord_GeoIndex : AbstractIndexCreationTask<GeoRecord>
{
public GeoRecord_GeoIndex()
{
Map = records => from @record in records
select new
{
IndexName = "geoIndex",
record.SearchId,
Coordinates = CreateSpatialField(@record.Latitude, @record.Longitude)
};
}
}
我可以使用空间查询过滤所有 GeoRecord,如下所示:
await session
.Query<GeoRecord, GeoRecord_GeoIndex>()
.Spatial("Coordinates", factory => factory.Within(shapeWkt: wkt))
.ToListAsync();
但是我想通过 SearchId 和坐标进行过滤,我得到了这个解决方案,但是我想了解它是否使用 GeoRecord_GeoIndex 而不是过滤来自 GeoRecord 的结果。
await session.Advanced.AsyncDocumentQuery<GeoRecord, GeoRecord_GeoIndex>()
.WhereIn("SearchId", activeSearchIds)
.Intersect()
.Spatial("Coordinates", criteria => criteria.Within(shapeWkt:wkt))
.ToListAsync();
【问题讨论】:
标签: ravendb