Documentation Center

Configuring mapping of custom locale names to Elasticsearch languages

If you use custom strings to denote the language of your DITA content, you need to configure how those custom strings map to Elasticsearch languages.

About this task

The Elasticsearch search engine indexes search strings by two-letter language codes (for example, fr for French). In SDL Tridion Docs, DITA content can denote its language the same way (for example, using en for English). But the DITA content can also use a five-character language-plus-locale string (for example, en-us for US English) or a custom string (for example, Anglais for English) to denote the content language.

By default, SDL Tridion Docs assumes that the first two characters of the DITA language value denote the correct Elasticsearch language in which to index. This approach works for strings such as en and en-us: both resolve to en, the right Elastisearch language. But this approach does not work for strings like Anglais, which resolves to the meaningless string An. In that last case, you must configure how your custom language values map to Elasticsearch languages.

Procedure

  1. In the configuration location of the microservice, open the file bootstrap.json for editing.
  2. In the list of property-value pairs, add the following line:
    "initial-documents": "MYLANGUAGEMAPPING"

    where MYLANGUAGEMAPPING is the name of the JSON file that you will be creating for your mappings, for example, locale-config.json.

  3. Save and close bootstrap.json.
  4. Create a new plain-text file with the name MYLANGUAGEMAPPING, for example, locale-config.json.
  5. Give this file the following content:
    {
      "mapping": "locale-to-language",
      "documents": [
        {
          "id": "locale-map",
          "values": [
            {
              "key": "ESLANG1",
              "values": [
                "CUSTOMLANGVALUE11",
                "CUSTOMLANGVALUE12",
                ...
              ]
            },
            {
              "key": "ESLANG2",
              "values": [
                "CUSTOMLANGVALUE21",
                "CUSTOMLANGVALUE22",
                ...
              ]
            },
            ...
          ]
        }
      ]
    }
    where:
    • ESLANG1, ESLANG2 and so on are Elasticsearch languages codes, such as fr and en.
    • CUSTOMLANGVALUE11, CUSTOMLANGVALUE12 and so on are DITA language codes that should map to ESLANG1.
    • CUSTOMLANGVALUE21, CUSTOMLANGVALUE22 and so on are DITA language codes that should map to ESLANG2.
  6. Save and close your file.

What to do next

The mapping file you created is configured in the bootstrap file. The very first time you install the microservice, you set a switch to ensure that the microservice reads the bootstrap configuration and applies the mapping to Elasticsearch.