Multiple language support : Object level analyzer mapping

Currently based on the FAQs and Elastic document portal there are only 2 ways to configure different language,

  1. Configure at the document level
  2. Configure at the field level

The above configuration styles are too limiting, if there are multiple fields that require to be on the same language, then there should be a way to group them together and assign a language type.

Is it possible to separate the language in the same document but at different nested level ? See the mapping structure below,

{
  "properties": {
    "Info": {
      "type": "object",
      "properties": {
        "EntityId": {
          "type": "long"
        }
      }
    },
    "Context": {
      "type": "nested",
      "properties": {
        "de": {
          "type": "nested",
          "analyzer": "german",
          "properties": {
            "title": {
              "type": "string"
            },
            "description": {
              "type": "string"
            },
            "description2": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}

I tried some other way before but it didn't work, see my discussion link here.

If it is not possible, should we create a feature request ?

Thanks!.

It is not possible to configure analyzers for all fields in a nested object. Instead you have to configure them on a field per field basis.

Note that type level analyzers have also been removed in 2.0 (https://github.com/elastic/elasticsearch/issues/8874 ) . Instead you can set an index level default, but that of course doesn't cover your use case.

Hi Boaz,

Thanks for the detailed reply. It makes a lot of sense now. As you mention index level is not an option for us b/c of the number of indexes we have to create and manage. If that will make it easy then I will look in to the different style deployment option for my project.

I will keep the field level for now.

Thanks,
-Shiv

Note that you can also use dynamic templates for fields and use the path_match option to match anything bellow the de tag. The downside there is that it will only work if fields do not already exist in the mapping. For any field you add manually you have to specify an analyzer. See https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#path-match-unmatch