我有以下类(class)
public class MyLayer
{
public List<MyLocation> Locations { get; set; }
}
public class MyLocation
{
public string Name { get; set; }
public MyCoordinate Coordinate { get; set; }
}
public class MyCoordinate
{
public double Lat { get; set; }
public double Lon { get; set; }
}
并用此代码索引对象
var node = new Uri("http://localhost:9200");
string indexName = "geopoint-tests2";
var settings = new ConnectionSettings(
node,
defaultIndex: "geopoint-tests2"
);
var client = new ElasticClient(settings);
var rootNodeInfo = client.RootNodeInfo();
if (!rootNodeInfo.ConnectionStatus.Success)
throw new ApplicationException("Could not connect to Elasticsearch!",
rootNodeInfo.ConnectionStatus.OriginalException);
client.CreateIndex(indexName, s => s
.AddMapping<MyLocation>(f => f
.MapFromAttributes()
.Properties(p => p
.GeoPoint(g => g.Name(n => n.Coordinate).IndexLatLon()))));
var loc = new MyLayer()
{
Locations = new List<MyLocation>()
};
loc.Locations.AddRange(new []
{
createLocation("Amsterdam", 52.3740300, 4.8896900),
createLocation("Rotterdam", 51.9225000, 4.4791700),
createLocation("Utrecht", 52.0908300, 5.1222200),
createLocation("Den Haag", 52.0908300, 5.1222200)
});
client.Index(loc);
如您所愿,我希望为位置数组建立索引,但是由于某些原因,我无法在kibana Tile map 中看到地理位置索引,当我为MyLocation的平面类型建立索引时,我看到了具有 map 可视化效果的地理位置索引。
在kibana 4.0中,我看到位置未建立索引-但无法确定如何建立索引...
问题出在代码吗?kibana中的索引?我对位置数组进行索引的方法?
谢谢您的时间和帮助:)
最佳答案
我在此模型上取得了成功:
internal class Location
{
[JsonProperty(PropertyName = "lat")]
public double Latitude { get; set; }
[JsonProperty(PropertyName = "lon")]
public double Longitude { get; set; }
}
然后将其映射为:
.MapFromAttributes()
.Properties(p =>
p.GeoPoint(s =>
s.Name(n => n.Location).IndexGeoHash().IndexLatLon().GeoHashPrecision(12)
)
)
然后它出现在基巴纳
关于c# - C#嵌套Elasticsearch地理点阵列索引未在Kibana中显示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31011824/