我如何添加一个not_analyzed字段到Elasticsearch

本文关键字:not analyzed 字段 Elasticsearch 一个 何添加 添加 | 更新日期: 2023-09-27 18:07:56

到目前为止,我使用NEST将数据索引到Elasticsearch中。当我试图使用以下代码将其中一个字段索引为not_analyzed时:

 var settings = new ConnectionSettings(
                node,
                defaultIndex: "resourceid5_analyzed1"
            )
            .SetDefaultPropertyNameInferrer(p => p);
            var client = new ElasticClient(settings);
            var response = client.Map<GoodDataAttribute>(m => m.MapFromAttributes()
                .Properties(props => props
                .String(s1 => s1
                .Name(p => p.ResourceGroup)
                .Analyzer("keyword")
                .IncludeInAll(false)
                .Index(FieldIndexOption.NotAnalyzed)
                .OmitNorms(true))));

我已经使用SetDefaultPropertyNameInferrer来禁用弹性属性的驼峰情况我使用的是NEST 1.7版提前感谢

我如何添加一个not_analyzed字段到Elasticsearch

如果你想更新一个已经存在的映射,那么你不能把一个已经存在的字段从"analyzed"改为"not_analyzed"。

要做到这一点,您需要删除索引

https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-intro.html updating-a-mapping