Elasticsearch 6 建立索引報錯 invalid_index_name_exception Invalid index name [testDemo], must be lowercase

東耳佳茗發表於2020-11-05

Elasticsearch 6 建立索引報錯:

Invalid index name [testDemo], must be lowercase

原因:Elasticsearch 6 預設索引型別是_doc,如果想改變則要指定索引型別

示例:

PUT testDemo
{
  "mappings": {
    "properties": {
      "name": {
        "type": "text"
      },
      "location": {
        "type": "geo_point"
      }
    }
   }
}

返回:

{
  "error": {
    "root_cause": [
      {
        "type": "invalid_index_name_exception",
        "reason": "Invalid index name [testDemo], must be lowercase",
        "index_uuid": "_na_",
        "index": "testDemo"
      }
    ],
    "type": "invalid_index_name_exception",
    "reason": "Invalid index name [testDemo], must be lowercase",
    "index_uuid": "_na_",
    "index": "testDemo"
  },
  "status": 400
}

指定索引型別:

PUT testDemo
{
  "mappings": {
    "product": {
    "properties": {
      "name": {
        "type": "text"
      },
      "location": {
        "type": "geo_point"
      }
    }
   }
  }
}

結果:

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "testDemo"
}

product為指定索引型別

相關文章