elasticsearch,nest,C#,elasticsearch,Nest" /> elasticsearch,nest,C#,elasticsearch,Nest" />

C# 嵌套与弹性搜索映射

C# 嵌套与弹性搜索映射,c#,elasticsearch,nest,C#,elasticsearch,Nest,我正在尝试将多个分析器映射到弹性类型中的字段。如果我使用ElasticAttribute映射分析器: [ElasticProperty(Analyzer = "fulltext")] public string LongDescription { get; set; } 我查看创建的请求,我得到: "name": { "type": "string", "analyzer": "fulltext" }, 为了将多个分析器映射到同一字段,我使用Fluent映射并

我正在尝试将多个分析器映射到弹性类型中的字段。如果我使用ElasticAttribute映射分析器:

[ElasticProperty(Analyzer = "fulltext")]
public string LongDescription { get; set; }
我查看创建的请求,我得到:

"name": {
      "type": "string",
      "analyzer": "fulltext"
    },
为了将多个分析器映射到同一字段,我使用Fluent映射并添加多字段:

.Properties(prop => prop
                    .MultiField(mf => mf
                        .Name(p => p.Name)
                        .Fields(f => f
                            .String(
                                s =>
                                    s.Name(n => n.Name)
                                        .IndexAnalyzer("autocomplete_analyzer")
                                        .IncludeInAll(false)
                                        .Index(FieldIndexOption.not_analyzed))
                            .String(
                                s =>
                                    s.Name(n => n.Name)
                                        .IndexAnalyzer("fulltext")
                                        .IncludeInAll(false)
                                        .Index(FieldIndexOption.not_analyzed))
                        )
                    )
                )
生成的请求如下所示:

 "name": {
      "type": "multi_field",
      "fields": {
        "name": {
          "type": "string",
          "index": "not_analyzed",
          "index_analyzer": "autocomplete_analyzer",
          "include_in_all": false
        },
        "name": {
          "type": "string",
          "index": "not_analyzed",
          "index_analyzer": "fulltext",
          "include_in_all": false
        }
      }
    },

我对“analyzer”/“index_analyzer”属性特别感兴趣。使用fluent mapping,我只能设置IndexAnalyzer或SearchAnalyzer。我理解IndexAnalyzer和SearchAnalyzer之间的区别,但是当我使用ElasticAttribute时,“analyzer”属性是什么?这是否意味着索引和搜索设置相同?

仅指定
分析器
实际上是同时设置
索引分析器
搜索分析器
analyzer
是elasticsearch属性,而不是NEST的一些神奇行为

fluent映射缺少
.Analyzer()
方法,该方法现在添加到1.0中