‘mapper_parsing_EXCEPTION’非法字段[IGNORIED_OBLE],只能在字段内指定字段‘ElasticSearch中的错误

fykwrbwg  于 2022-10-06  发布在  ElasticSearch
关注(0)|答案(1)|浏览(173)

我刚接触Elelity Search,我正在尝试为索引创建Map文件这是我用于创建索引的Map文件

{
"mapping": {
    "properties": {
        "TotalCapacity": {
            "type": "long"
        },
        "DiskUseState": {
            "type": "text",
            "fields": {
                "type": "keyword",
                "ignored_above": 256
            }
        },
        "DriveHostName": {
            "type": "text",
            "fields": {
                "type": "keyword",
                "ignored_above": 256
            }
        },
        "ModelNumber": {
            "type": "text",
            "fields": {
                "type": "keyword",
                "ignored_above": 256
            }
        },
        "DriveNodeUuid": {
            "type": "text",
            "fields": {
                "type": "keyword",
                "ignored_above": 256
            }
        },
        "DrivePath": {
            "type": "text",
            "fields": {
                "type": "keyword",
                "ignored_above": 256
            }
        },
        "DriveProtocol": {
            "type": "text",
            "fields": {
                "type": "keyword",
                "ignored_above": 256
            }
        }  
    }

}

}

当我尝试创建索引时,我收到以下错误

'mapper_parsing_exception' illegal field [ignored_above], only fields can be specified inside fields' error in elastic search.

不知道出了什么问题。任何帮助都适用于Elasticearch版本:7.1.0

ca1c2owp

ca1c2owp1#

您的Map配置有两个问题:

首先,它应该是ignore_above,而不是ignored_above

第二,您没有给出子字段名。您的字段Map应该如下所示,这样您就可以使用DiskUseState.keyword名称访问keyword类型的字段:

"DiskUseState": {
        "type": "text",
        "fields": {
          "keyword": {           <---- this you have not given in your mapping
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }

正确的字段Map

{
  "mappings": {
    "properties": {
      "TotalCapacity": {
        "type": "long"
      },
      "DiskUseState": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "DriveHostName": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "ModelNumber": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "DriveNodeUuid": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "DrivePath": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "DriveProtocol": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  }
}

相关问题