简体   繁体   中英

“null_value” not permitted for “text” field?

I am trying to define a "null_value" for a "text" field (ver. 5.1.1). Like so:

PUT students
{
  "mappings": {
    "student": {
      "properties": {
        "first_name": {
          "type": "text",
          "null_value": "No First Name"
        }
      }
    }
  }
}

This results in an error:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [first_name] has unsupported parameters:  [null_value : No First Name]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [student]: Mapping definition for [first_name] has unsupported parameters:  [null_value : No First Name]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Mapping definition for [first_name] has unsupported parameters:  [null_value : No First Name]"
    }
  },
  "status": 400
}

But if "first_name" is marked as "type": "keyword" , it succeeds. Looking at the documentation , it doesn't state that "null_value" applies only to "keyword" typed fields. Am I missing something here?

null_value is not allowed in text datatype. Take a look at table for allowed parameters for text datatype. https://www.elastic.co/guide/en/elasticsearch/reference/5.1/text.html#text-params

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM