Monday 30 July 2018

Multi-language elastic search mapping setup

I have documents stored in MongoDB like so:

const demoArticle = {
  created: new Date(),
  title: [{
    language: 'english',
    value: 'This is the english title'
  }, {
    language: 'dutch',
    value: 'Dit is de nederlandse titel'
  }]
}

I want to add analyzers to specific languages, which is normally specified like so:

"mappings": {
   "article": {
      "properties": {
         "created": {
            "type": "date"
         },
         "title.value": {
           "type": "text",
           "analyzer": "english"
         }
      }
   }
}

The problem is however: depending on the language set on the child level, it should have an analyzer set according to that same language.

I've stumbled upon Dynamic Templates in ElasticSearch but I was not quite convinced this is suited for this use-case.

Any suggestions?



from Multi-language elastic search mapping setup

No comments:

Post a Comment