Indexing RavenDB-如何将WKT圆形添加到索引?
如何将计算出的形状添加到索引中 我有一节课Indexing RavenDB-如何将WKT圆形添加到索引?,indexing,ravendb,spatial,Indexing,Ravendb,Spatial,如何将计算出的形状添加到索引中 我有一节课 public class Partner { public double Latitude { get; set; } public double Longitude { get; set; } public double WorkingRadius { get; set; } public double WorkingRadiusShape { get { return s
public class Partner
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public double WorkingRadius { get; set; }
public double WorkingRadiusShape
{
get
{
return string.Format("Circle({0},{1}, d={2})", Latitude, Longitude, WorkingRadius);
}
}
}
使用以下索引
public class PartnersByLocation : AbstractIndexCreationTask<Partner>
{
public PartnersByLocation()
{
Map = partners => from doc in partners
select new
{
WorkingRadiusShape = doc.WorkingRadiusShape
};
Spatial(x => x.WorkingRadiusShape, options => options.Geography.Default());
}
}
公共类PartnersByLocation:AbstractIndexCreationTask
{
公共合作伙伴定位()
{
Map=partners=>来自partners中的文档
选择新的
{
WorkingRadiusShape=doc.WorkingRadiusShape
};
Spatial(x=>x.WorkingRadiusShape,options=>options.Geography.Default());
}
}
我重建并运行应用程序,但索引PartnersByLocation为空。我不确定我做错了什么。索引没有报告任何错误,我已经检查了合作伙伴集合是否为写入WorkingRadiusShape属性的属性设置了值。我的语法或方法有什么根本性的错误吗?我发现了
Map = partners => from doc in partners
where doc.AbilityKeyIds != null
select new
{
WorkingRadiusShape = string.Format("Circle({0},{1}, d={2})", doc.Latitude, doc.Longitude, doc.WorkingRadius)
};
Spatial(x => x.WorkingRadiusShape, options => options.Geography.Default());
关键是在索引时移动并分配WorkingRadiusShape,否则属性仅在文档读/写时更新。因此,如果存在任何已弃用/无效的条目,则在写入索引时不会更新这些条目,索引将中断。在我的例子中,我在我的一个合作伙伴条目中存储了10000个WorkingRadius。此值导致索引中断,因为最大值为180,可以作为“d”传递。在指定形状时,请注意该最大值