gpt4 book ai didi

elasticsearch - 如何在Elastic Search中插入数据

转载 作者:行者123 更新时间:2023-12-03 00:50:41 28 4
gpt4 key购买 nike

在我的dotnet核心项目中,我需要在 flex 搜索中插入数据。我正在使用波纹管代码进行插入。

List<Patient> employeeData = null;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:5001/api/Employee/GetAll");
request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
var data= reader.ReadToEnd();
reader.Close();
dataStream.Close();
employeeData = JsonConvert.DeserializeObject<List<Employee>>(data);
}
var lst = employeeData;
int count = 0;
foreach (var obj in lst)
{
count ++;
this.client.Index(obj, i => i
.Index("employee")
.Type("myEmployee")
.Id(count)
// .Refresh()
);
}

执行以上代码后,我使用波纹管网址检查插入的数据
localhost:9200/emp
我得到以下输出。
{"emp":{"aliases":{},"mappings":{"myEmpl":{"properties":{"firstName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"gEmailId":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"gMobile":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"wmployeeID":{"type":"long"},"registrationNo":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index":{"creation_date":"1547020635852","number_of_shards":"5","number_of_replicas":"1","uuid":"6kle4jzMQDSICnPsmATbDw","version":{"created":"6050499"},"provided_name":"emp"}}}}

我看不到任何数据。这有什么问题。

最佳答案

localhost:9200/emp返回索引“emp”的设置和映射。对于内容,请尝试localhost:9200/emp/_search

关于elasticsearch - 如何在Elastic Search中插入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54105793/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com