[英]C# nest elasticsearch geo point array index not shown in kibana
I have the following classes 我有以下课程
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; }
}
And this code to index objects 并用此代码索引对象
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);
As you can i want index an array of location but for some reason I can't see the geo index in kibana Tile map, when I indexed flat type of MyLocation i seen the geo index with the map visualzation. 如您所愿,我希望为位置数组建立索引,但由于某些原因,我无法在kibana Tile地图中看到地理位置索引,当为MyLocation的平面类型建立索引时,我看到了具有地图可视化效果的地理位置索引。
In kibana 4.0 I see that Location is not indexed - but could not figure how to index it... 在kibana 4.0中,我看到位置未编制索引-但无法确定如何编制索引...
Is the problem is with code?Index in kibana?My approch of indexing array of location? 问题出在代码吗?kibana中的索引?我对位置索引数组的处理方式?
Thank you for your time and help :) 谢谢您的时间和帮助:)
I've had success with this model: 我在此模型上取得了成功:
internal class Location
{
[JsonProperty(PropertyName = "lat")]
public double Latitude { get; set; }
[JsonProperty(PropertyName = "lon")]
public double Longitude { get; set; }
}
and then mapping it with: 然后将其映射为:
.MapFromAttributes()
.Properties(p =>
p.GeoPoint(s =>
s.Name(n => n.Location).IndexGeoHash().IndexLatLon().GeoHashPrecision(12)
)
)
Then it shows up in Kibana 然后它出现在基巴纳
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.