简体   繁体   English

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

[英]Multiple Mappings in elastic search for one single Index

I have some fields in elastic search type as string and index as not_analysed. 弹性搜索类型中的一些字段为字符串,索引为not_analysed。

while searching for the values of those fields some time I need index as analysed also. 在搜索那些字段的值的同时,我还需要索引。

So is it possible to do multiple mapping in elastic search for one single index. 因此,可以在弹性搜索中对单个索引进行多个映射。

In my case one for index as not_analysed and second one for index as analysed. 在我的情况下,一个索引为not_analysed,另一个索引为分析。

Thanks Mukesh Raghuwanshi 谢谢Mukesh Raghuwanshi

Yes of course, you can use multi-field for exactly this purpose. 是的,当然,您可以将multi-field用于此目的。 Your field needs to be declared as follows in your mapping type: 您的字段需要在映射类型中声明如下:

{
  "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"
          }
        }
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM