【发布时间】:2015-06-28 03:22:23
【问题描述】:
您好,我是弹性和嵌套的新手。 我使用了一个示例来说明如何索引地理点位置,因为我可以看到 kibana 地图中的地理点可视化。
这是我的数据结构:
public class LocationArray
{
public string ArrayNameArtical { get; set; }
[ElasticProperty(Type = FieldType.GeoPoint)]
public IEnumerable<Location> Locations { get; set; }
}
public class Location
{
public string Name { get; set; }
[ElasticProperty(Type = FieldType.GeoPoint)]
public Coordinate Coordinate { get; set; }
}
public class Coordinate
{
public double Lat { get; set; }
public double Lon { get; set; }
}
我的索引代码如下:
var response = client.CreateIndex(indexName, s => s
.AddMapping<Location>(f => f
.MapFromAttributes()
.Properties(p => p
.GeoPoint(g => g.Name(n => n.Coordinate).IndexGeoHash().IndexLatLon())
)
)
);
client.IndexMany(new[]{
new Location
{
Name = "Amsterdam",
Coordinate = new Coordinate { Lat = 52.3740300, Lon = 4.8896900}
},
new Location
{
Name = "Rotterdam",
Coordinate = new Coordinate { Lat = 51.9225000, Lon = 4.4791700}
},
new Location
{
Name = "Utrecht",
Coordinate = new Coordinate { Lat = 52.0908300, Lon = 5.1222200}
},new Location
{
Name = "Den Haag",
Coordinate = new Coordinate { Lat = 52.3740300, Lon = 4.8896900}
}
});
现在我想索引 LocationArray 类,似乎需要更改我的映射但我不知道该怎么做..无论如何我可以在 kibana 中看到数组数据,但无法在地图上查看它。 地理点的索引数组有问题吗?
【问题讨论】:
标签: c# arrays elasticsearch nest