【问题标题】:"Unable to Parse/Serialize body" in Kibana, ElasticSearch data populated with NESTKibana 中的“无法解析/序列化正文”,使用 NEST 填充的 ElasticSearch 数据
【发布时间】:2015-11-10 11:42:58
【问题描述】:

我在 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.

2.

3.

  1. JS 控制台出错:

有人知道为什么会发生这种情况吗?

【问题讨论】:

  • 您使用的是哪个 Kibana/Elasticsearch 版本?我想这是一个兼容性问题。
  • Kibana 4.1.2 和 ElasticSearch 1.7.3
  • 猜错了。我可以在您的屏幕截图中看到“type`1”;中间的反引号可能会破坏 JSON 解析。你能在你的 C# 代码中改变它吗?
  • 能不能显示无法解析的全身?

标签: c# elasticsearch kibana nest kibana-4


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-30
    • 2017-02-01
    • 2020-06-12
    • 1970-01-01
    相关资源
    最近更新 更多