0

I am trying to create an index with a custom default analyzer. I already checked the following questions:

but they didn't solve the issue.

Here is my schema:

put /emails
{
   "mappings": {
      "email": {
         "analyzer": "lkw",
         "properties": {
            "createdOn": {
               "type": "date",
               "store": true,
               "format": "strict_date_optional_time||epoch_millis"
            },
            "data": {
               "type": "object",
               "dynamic": "true"
            },
            "from": {
               "type": "string",
               "store": true
            },
            "id": {
               "type": "string",
               "store": true
            },
            "sentOn": {
               "type": "date",
               "store": true,
               "format": "strict_date_optional_time||epoch_millis"
            },
            "sesId": {
               "type": "string",
               "store": true
            },
            "subject": {
               "type": "string",
               "store": true,
               "analyzer": "standard"
            },
            "templates": {
               "properties": {
                  "html": {
                     "type": "string",
                     "store": true
                  },
                  "plainText": {
                     "type": "string",
                     "store": true
                  }
               }
            },
            "to": {
               "type": "string",
               "store": true
            },
            "type": {
               "type": "string",
               "store": true
            }
         }
      },
      "event": {
         "_parent": {
            "type": "email"
         },
         "analyzer": "lkw",
         "properties": {
            "id": {
               "type": "string",
               "store": true
            },
            "origin": {
               "type": "string",
               "store": true
            },
            "time": {
               "type": "date",
               "store": true,
               "format": "strict_date_optional_time||epoch_millis"
            },
            "type": {
               "type": "string",
               "store": true
            },
            "userAgent": {
               "type": "string",
               "store": true
            }
         }
      }
   },
   "settings": {
      "analysis": {
         "analyzer": {
            "lkw": {
               "tokenizer": "keyword",
               "filter": [
                  "lowercase"
               ],
               "type": "custom"
            }
         }
      }
   }
}

When I execute the command above, I get this error:

{
       "error": {
          "root_cause": [
             {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [analyzer : lkw]"
             }
          ],
          "type": "mapper_parsing_exception",
          "reason": "Failed to parse mapping [event]: Root mapping definition has unsupported parameters:  [analyzer : lkw]",
          "caused_by": {
             "type": "mapper_parsing_exception",
             "reason": "Root mapping definition has unsupported parameters:  [analyzer : lkw]"
          }
       },
       "status": 400
    }
4
  • Do you want your lkw analyzer to be applied to all string fields which don't have a specific analyzer? Commented Dec 10, 2016 at 5:43
  • Yes, that was the idea Commented Dec 11, 2016 at 5:22
  • Since you have only a few string fields, why not simply specifying your lkw analyzer where you need it, just like you did for the standard one? Commented Dec 11, 2016 at 7:54
  • I tried. I get the same error. Commented Dec 12, 2016 at 1:23

1 Answer 1

0

Since you have only a few string fields, I suggest you simply specify your lkw analyzer where you need it, just like you did for the standard one:

PUT /emails
{
   "mappings": {
      "email": {
         "properties": {
            "createdOn": {
               "type": "date",
               "store": true,
               "format": "strict_date_optional_time||epoch_millis"
            },
            "data": {
               "type": "object",
               "dynamic": "true"
            },
            "from": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "id": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "sentOn": {
               "type": "date",
               "store": true,
               "format": "strict_date_optional_time||epoch_millis"
            },
            "sesId": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "subject": {
               "type": "string",
               "store": true,
               "analyzer": "standard"
            },
            "templates": {
               "properties": {
                  "html": {
                     "type": "string",
                     "store": true,
                     "analyzer": "lkw"
                  },
                  "plainText": {
                     "type": "string",
                     "store": true,
                     "analyzer": "lkw"
                  }
               }
            },
            "to": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "type": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            }
         }
      },
      "event": {
         "_parent": {
            "type": "email"
         },
         "properties": {
            "id": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "origin": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "time": {
               "type": "date",
               "store": true,
               "format": "strict_date_optional_time||epoch_millis"
            },
            "type": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            },
            "userAgent": {
               "type": "string",
               "store": true,
               "analyzer": "lkw"
            }
         }
      }
   },
   "settings": {
      "analysis": {
         "analyzer": {
            "lkw": {
               "tokenizer": "keyword",
               "filter": [
                  "lowercase"
               ],
               "type": "custom"
            }
         }
      }
   }
}
Sign up to request clarification or add additional context in comments.

5 Comments

I'll take this as the correct answer. Do you know why the other way is not working?
Because that was not a correct way of specifying an analyzer to be used for a field.
Trying to understand what I did wrong because I set the default analyzer on other indexes.
You simply need to call it default in your index settings for it to work.
I found out it was a breaking change 1.x => 2.x elastic.co/guide/en/elasticsearch/reference/2.0/… Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.