3

I have some fields in elastic search type as string and index as 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.

Thanks Mukesh Raghuwanshi

Mukesh
  • 422
  • 2
  • 4
  • 9
  • Its not clear what you're trying to achieve? If you need text search, you probably need analyzers. Why not just set the needed one? – Slam Aug 11 '15 at 10:21

1 Answers1

4

Yes of course, you can use multi-field for exactly this purpose. 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"
          }
        }
      }
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360