代码之家  ›  专栏  ›  技术社区  ›  John K

如何使用elasticsearch.net/nest 6.x更新文档类型的设置

  •  0
  • John K  · 技术社区  · 6 年前

    具体来说,我试图通过ElasticSearch.net和Nest 6.x API实现的是 example of setting dynamic=strict on the _doc type shown in this article using JSON .

    类型级别的设置也在 official docs

    2 回复  |  直到 6 年前
        1
  •  1
  •   Russ Cam    6 年前

    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"
    }
    

    strict behaviour for dynamic fields _doc testindex1

        2
  •  1
  •   John K    6 年前

    using Nest; // C# 
    
    var pd = PostData.String("{ \"dynamic\": \"strict\" }");
    var result = client.LowLevel.IndicesPutMappingPost<PutMappingResponse>(indexNm, "_doc", pd);
    

    client
    indexNm

    {
        "testindex1": {
            "aliases": {},
            "mappings": {
                "_doc": {
                    "dynamic": "strict",
    

    dynamic: strict _doc