嵌套和弹性搜索-映射 [英] Nest and Elastic Search - Mapping

查看:71
本文介绍了嵌套和弹性搜索-映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to map multiple analyzers to a field in my elastic type. If I use an ElasticAttribute to map an analyzer:

[ElasticProperty(Analyzer = "fulltext")]
public string LongDescription { get; set; }

然后查看创建的请求:

"name": {
      "type": "string",
      "analyzer": "fulltext"
    },

为了将多个分析器映射到同一字段,我使用Fluent映射并添加一个多字段:

In order to map multiple analyzers to the same field, I use Fluent mapping and add a multifield:

.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"属性特别感兴趣.使用流畅的映射,我只能设置IndexAnalyzer或SearchAnalyzer.我了解IndexAnalyzer和SearchAnalyzer之间的区别,但是当我使用ElasticAttribute时,"analyzer"属性是什么?这是否仅表示索引和搜索设置相同?

I am specifically interested in the "analyzer"/"index_analyzer" properties. With fluent mapping, I can only set IndexAnalyzer or SearchAnalyzer. I understand the difference between IndexAnalyzer and SearchAnalyzer, but what is the "analyzer" property when I use an ElasticAttribute? Does that just mean the Index and Search are set the same?

推荐答案

仅指定analyzer实际上是同时设置index_analyzersearch_analyzer. analyzer是弹性搜索属性,不是NEST的某些魔术行为.

Just specifying analyzer is indeed setting index_analyzer and search_analyzer at the same time. analyzer is an elasticsearch property and not some magic behavior from NEST.

流畅的映射缺少.Analyzer()方法,该方法现在已添加到1.0中!

The fluent mapping is missing the .Analyzer() method, this is now added in 1.0!

这篇关于嵌套和弹性搜索-映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆