【问题标题】:Multiple Mappings in elastic search for one single Index一个索引的弹性搜索中的多个映射
【发布时间】:2015-08-11 09:55:01
【问题描述】:

我有一些弹性搜索类型的字段为字符串,索引为 not_analysed。

在搜索这些字段的值时,有时我还需要分析索引。

那么是否可以在弹性搜索中为单个索引进行多个映射。

在我的例子中,第一个索引为 not_analysed,第二个索引为已分析。

谢谢 穆克什·拉古万希

【问题讨论】:

  • 不清楚您要达到什么目的?如果您需要文本搜索,您可能需要分析器。为什么不只设置需要的?

标签: elasticsearch elasticsearch-net


【解决方案1】:

是的,当然,您可以使用multi-field 来达到这个目的。您的字段需要在映射类型中声明如下:

{
  "your_type" : {
    "properties" : {
      "your_field" : {                   <-- this is the analyzed version of the field
        "type" : "string",
        "index" : "analyzed",
        "fields" : {
          "raw" : {                      <-- this is the not_analyzed sub-field
            "type" : "string", 
            "index" : "not_analyzed"
          }
        }
      }
    }
  }
}

【讨论】:

    猜你喜欢
    • 2017-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-27
    相关资源
    最近更新 更多