如何使用 elasticsearch 更新 _doc 类型的设置。net/nest 6.x
How to update a setting on the _doc type using elasticsearch.net/nest 6.x
具体来说,我试图通过 Elasticsearch.Net 和 NEST 6.x API 实现的是 example of setting dynamic=strict on the _doc type shown in this article using JSON。
类型级别的设置在official docs
中也有提到
我深入低级客户端来实现这个解决方案,而当我发布问题时,我是在高级客户端中搜索的。
using Nest; // C#
var pd = PostData.String("{ \"dynamic\": \"strict\" }");
var result = client.LowLevel.IndicesPutMappingPost<PutMappingResponse>(indexNm, "_doc", pd);
其中 client
变量是一个 ElasticClient 实例。
indexNm
变量是一个包含 "testindex1"
的字符串
结果
{
"testindex1": {
"aliases": {},
"mappings": {
"_doc": {
"dynamic": "strict",
我看到 dynamic: strict
已按预期添加到 _doc
类型映射中。
您可以使用高级客户端发送此请求
var client = new ElasticClient();
var putMappingResponse = client.Map<object>(m => m
.Index("testindex1")
.Type("_doc")
.Dynamic(DynamicMapping.Strict)
);
这将发送以下请求
PUT http://localhost:9200/testindex1/_doc/_mapping
{
"dynamic": "strict"
}
对于 testindex1
索引中的 _doc
类型,最终结果将是 strict behaviour for dynamic fields 的结果。
具体来说,我试图通过 Elasticsearch.Net 和 NEST 6.x API 实现的是 example of setting dynamic=strict on the _doc type shown in this article using JSON。
类型级别的设置在official docs
中也有提到我深入低级客户端来实现这个解决方案,而当我发布问题时,我是在高级客户端中搜索的。
using Nest; // C#
var pd = PostData.String("{ \"dynamic\": \"strict\" }");
var result = client.LowLevel.IndicesPutMappingPost<PutMappingResponse>(indexNm, "_doc", pd);
其中 client
变量是一个 ElasticClient 实例。
indexNm
变量是一个包含 "testindex1"
结果
{
"testindex1": {
"aliases": {},
"mappings": {
"_doc": {
"dynamic": "strict",
我看到 dynamic: strict
已按预期添加到 _doc
类型映射中。
您可以使用高级客户端发送此请求
var client = new ElasticClient();
var putMappingResponse = client.Map<object>(m => m
.Index("testindex1")
.Type("_doc")
.Dynamic(DynamicMapping.Strict)
);
这将发送以下请求
PUT http://localhost:9200/testindex1/_doc/_mapping
{
"dynamic": "strict"
}
对于 testindex1
索引中的 _doc
类型,最终结果将是 strict behaviour for dynamic fields 的结果。