Elasticsearch upgrade 2.3.1 Nest client Raw String

可紊 提交于 2019-12-01 06:27:53

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!