C#nest弹性搜索地理点数组索引未显示在kibana中 [英] C# nest elasticsearch geo point array index not shown in kibana

查看:163
本文介绍了C#nest弹性搜索地理点数组索引未显示在kibana中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下课程

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平铺地图,当我索引平面类型的MyLocation我看到地理索引与地图visualzation。

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 4.0我看到位置没有索引 - 但无法确定如何索引...

In kibana 4.0 I see that Location is not indexed - but could not figure how to index it...

问题是与代码有关吗?在kibana中的索引?我的索引位置数组?

Is the problem is with code?Index in kibana?My approch of indexing array of location?

感谢您的时间和帮助:)

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; }

}

然后将其映射到:

.MapFromAttributes()
    .Properties(p =>
        p.GeoPoint(s =>
            s.Name(n => n.Location).IndexGeoHash().IndexLatLon().GeoHashPrecision(12)
            )
        )

然后它显示在Kibana

Then it shows up in Kibana

这篇关于C#nest弹性搜索地理点数组索引未显示在kibana中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆