在Kibana中,“无法解析/序列化主体”,使用NEST填充ElasticSearch数据

时间:2015-11-10 11:42:58

标签: c# elasticsearch kibana nest kibana-4

我在C#中有以下代码可以正常工作:

class Person {
    public DateTime time { get; set; }
    public string id { get; set; }
    public string name { get; set; }
    public int age { get; set; }
}


...Main()

    var node = new Uri("http://localhost:9200");
    var settings = new ConnectionSettings(
        node,
        defaultIndex: "my-new-app"
    );
    var client = new ElasticClient(settings);

    List<Person> people = new List<Person>();
    for (int i = 0; i < 10; i++ )
    {

        people.Add(new Person() { age = 1, id = i.ToString(), name = string.Format("Name: {0}", i), time = DateTime.Now });
        Thread.Sleep(500);
    }

    var index = client.Index(people);

但是当我尝试在Kibana中访问我的数据时:

1

enter image description here

2

enter image description here

3

enter image description here

  1. JS控制台错误:
  2. enter image description here

    有人知道为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

解决方案是单独添加每个条目:

var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(
    node,
    defaultIndex: "my-new-app"
);
var client = new ElasticClient(settings);

for (int i = 0; i < 10; i++ )
{

    Thread.Sleep(500);
    var index = client.Index(new Person() { age = 1, id = i.ToString(), name = string.Format("Name: {0}", i), time = DateTime.Now });
}