2
votes

My mapping has 4 string fields:

  • "name"
  • "info"
  • "language"
  • "genre"

and 4 custom analyzers:

  • "english_custom_analyzer"
  • "french_custom_analyzer"
  • "spanish_custom_analyzer"
  • "arabic_custom_analyzer"

I want to be able to specify the Analyzer to use when inserting the document using the language field. So If the language is English I want to use the English analyzer for documents field and if the language is French, I want to use the French Analayzer.

I tried to create an extra field called, "language_name_analyzer", populate that field with the analyzer name at insert time and set the analyzer name to "language_name_analyzer". But I get this error:

Cause: org.elasticsearch.index.mapper.MapperParsingException: Analyzer [language_name_analyzer] not found for field [datacontent_onair_title]

Thank you

1

1 Answers

1
votes

First of all, I would recommend to reconsider using this feature since it has been removed from the next major release of elasticsearch 2.0.

If you still want to use it, you need to specify the path to the language_name_analyzer field in the mapping:

{
    "type1" : {
        "_analyzer" : {
            "path" : "language_name_analyzer"
        },
        "properties": {
            //// your other fields
        }
    }
}