【问题标题】:C# nest elasticsearch geo point array index not shown in kibanaC# 嵌套弹性搜索地理点数组索引未在 kibana 中显示
【发布时间】:2015-06-23 19:30:17
【问题描述】:

我有以下课程

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 地图中看不到地理索引,当我索引 MyLocation 的平面类型时,我看到了带有地图可视化的地理索引。

在 kibana 4.0 中,我看到 Location 没有被索引 - 但不知道如何索引它......

问题出在代码上吗?kibana 中的索引?我对位置数组的索引方法?

感谢您的时间和帮助:)

【问题讨论】:

    标签: c# elasticsearch nest kibana-4 geopoints


    【解决方案1】:

    我在这个模型上取得了成功:

    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 中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 2020-02-07
      • 1970-01-01
      相关资源
      最近更新 更多