我在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
答案 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 });
}