adding analyser in ElasticSearch field of type array

970 Views Asked by At

I have an elastic search object in which one field is an array type. now i want to apply a different analyser than standard default one. when i pass analyzer in index definition, it is throwing error. how can i do this?

In the below example, skills contains an array of values. all i want is to apply different analysers and see results. how can i achieve that?

      "skills": {
        "type": "object",
        "analyzer": "simple"
      },
      "profile": {
        "type": "text",
        "analyzer": "simple"
      },
      "job_title": {
        "type": "text",
        "analyzer": "simple"
      },

Getting below error:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [skills] has unsupported parameters:  [analyzer : simple]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Mapping definition for [skills] has unsupported parameters:  [analyzer : simple]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Mapping definition for [skills] has unsupported parameters:  [analyzer : simple]"
    }
  },
  "status": 400
}
1

There are 1 best solutions below

0
On

There's no dedicated array data type in ES. If skills is an array of keywords, you can use type:text & analyzer:simple.

Tip: if you'd like to quickly iterate on the effects of different analyzers, you can use the _analyze endpoint without having to drop/adjust/reindex each time:

GET _analyze
{
  "text": [
    "lorem",
    "ipsum",
    "123abc"
  ],
  "analyzer": "simple"
}