Elasticsearch upgrade 2.3.1 Nest client Raw String

后端 未结 1 1184
耶瑟儿~
耶瑟儿~ 2021-01-13 06:45

While upgrading to elastic 2.3.1 I am running into a snag with the .Net Nest Client.

In Nest 1.0, I could read an index\'s settings from a file and configure the ind

相关标签:
1条回答
  • 2021-01-13 07:09

    ElasticClient.Raw has been renamed to ElasticClient.LowLevel.

    This is how you can compose your request in NEST 2.x.

    _elastic.Client.LowLevel.IndicesCreate<object>(indexName, File.ReadAllText("index.json"));
    

    Content of index.json file:

    {
        "settings" : {
            "index" : {
                "number_of_shards" : 1,
                "number_of_replicas" : 1
            },
            "analysis" : {
                "analyzer" : {
                    "analyzer-name" : {
                        "type" : "custom",
                        "tokenizer" : "keyword",
                        "filter" : "lowercase"
                    }
                }
            },
            "mappings" : {
                "employeeinfo" : {
                    "properties" : {
                        "age" : {
                            "type" : "long"
                        },
                        "experienceInYears" : {
                            "type" : "long"
                        },
                        "name" : {
                            "type" : "string",
                            "analyzer" : "analyzer-name"
                        }
                    }
                }
            }
        }
    }
    

    Hope it helps.

    0 讨论(0)
提交回复
热议问题