nab*_*adi 10 elasticsearch nest asp.net-core
我使用 ElasticSearch 8.1.2 和 Nest 17.7.1
var settings = new ConnectionSettings(new Uri("http://localhost:9200/"))
.CertificateFingerprint("A5:8B:07:2D:A9:E8:53:CE:GB:C0:15:CE:6E:DF:9C:65:89:A3:AC:D2:94:2C:46:BD:85:23:20:6B:F2:69:B3:88")
.BasicAuthentication("elastic", "-L-uXRg5=iOXGFgebP68")
.DeadTimeout(TimeSpan.FromSeconds(300))
.DefaultIndex("people");
var client = new ElasticClient(settings);
var person = new Person
{
Id = 1,
FirstName = "Martijn",
LastName = "Laarman"
};
var asyncIndexResponse = await client.IndexDocumentAsync(person);
return Task.CompletedTask;
Run Code Online (Sandbox Code Playgroud)
错误消息:消息 =“由于产品检查调用不成功,客户端无法验证服务器是否为 Elasticsearch。如果服务器运行不受支持的产品,某些功能可能不兼容。调用:状态代码未知,来自:GET /”
在连接设置中启用兼容性标头:
settings.EnableApiVersioningHeader(); // enable ES 7.x compatibility on ES 8.x servers
Run Code Online (Sandbox Code Playgroud)
此处记录启用兼容模式
| 归档时间: |
|
| 查看次数: |
13509 次 |
| 最近记录: |