C#nest elasticsearch geo point数组索引未在kibana中显示

时间:2015-06-23 19:30:17

标签: c# elasticsearch nest kibana-4 geopoints

我有以下课程

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

此代码用于索引对象

/var/lib/docker/aufs

因为你可以我想索引一个位置数组但由于某种原因我无法在kibana Tile地图中看到地理索引,当我索引平面类型的MyLocation时,我看到地理索引与地图可视化。< / p>

在kibana 4.0中,我看到Location没有编入索引 - 但无法确定如何编制索引......

问题是代码吗?kibana中的索引?我的索引位置数组的大小?

感谢您的时间和帮助:)

1 个答案:

答案 0 :(得分: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