弹性搜索单个索引的多个映射

时间:2015-08-11 09:55:02

标签: elasticsearch elasticsearch-net

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

在搜索那些字段的值时,有时我也需要索引进行分析。

因此可以在弹性搜索中对一个索引进行多次映射。

在我的情况下,一个用于索引为not_analysed,另一个用于索引的分析。

由于 Mukesh Raghuwanshi

1 个答案:

答案 0 :(得分:4)

是的,当然,您可以将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"
          }
        }
      }
    }
  }
}