Mapping related question?

I have string field value such as "/worldrediff/style_3_16/home_tile_us_18.css"
when add aggregation on same field on bar chart, it splits like "/", "worldrediff", "style" etc.
and shows different bars for each terms.

I read from blog to use {field}.raw in mapping and use index template and so

Question: When i define index template do in need to do mapping for each field or just the one which i would wish {field}.raw.

Can I use it in that way?

what you need to do is update the field mapping to not_analyzed for just the field that you are interested in, so it wouldn't split each term in the value.

for example, for a field name field1

"field1": {
 "type": "string",
  "fields": {
      "raw": {
            "type": "string",
            "index": "not_analyzed"
       }
   }
}

now the field "field1" would be analyzed, but "field.raw" would not be, which should work for your case.

Thanks,
Madhav.