【问题标题】:Can't create two Types to same index elasticsearch & Kibana无法为同一索引弹性搜索和 Kibana 创建两种类型
【发布时间】:2018-05-17 21:18:42
【问题描述】:

我是 elasticsearch 和 kibana 的新手

我正在用 elasticsearch 做一些练习(创建索引、类型和文档..)

我创建了一个类型为“building”的索引“business”

put /business/building/217
{
  "adresse":"11 Pen Ave",
  "floors":5,
  "offices":7,
  "loc":{
    "lat":40.693479,
    "lon":-73.983854
  }
}

这很有趣,但是当我尝试创建另一种这样的类型时

put /business/employee/330
{
  "name":"Richard Bell",
  "title":"Senior Accountant",
  "salar_usd":115000.00,
  "hiredate":"Jan 19, 2013"
}

然后我得到了这个错误

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Rejecting mapping update to [business] as the final mapping would have more than 1 type: [employee, building]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Rejecting mapping update to [business] as the final mapping would have more than 1 type: [employee, building]"
  },
  "status": 400
}

【问题讨论】:

    标签: elasticsearch kibana


    【解决方案1】:

    您可能正在运行 Elasticsearch 版本 6,并且从该版本开始,ES 不允许您在任何给定索引中创建 more than one type

    您需要将每种文档类型存储在专用索引中,例如

    PUT /business/building/217
    {
      "adresse":"11 Pen Ave",
      "floors":5,
      "offices":7,
      "loc":{
        "lat":40.693479,
        "lon":-73.983854
      }
    }
    
    PUT /employees/employee/330
    {
      "name":"Richard Bell",
      "title":"Senior Accountant",
      "salar_usd":115000.00,
      "hiredate":"Jan 19, 2013"
    }
    

    【讨论】:

    • 这个运气好吗?
    【解决方案2】:

    更多信息请参见https://www.elastic.co/guide/en/elasticsearch/reference/6.2/removal-of-types.html

    Elasticsearch 6.x 在 6.x 中创建的索引仅允许每个索引使用单一类型。该类型可以使用任何名称,但只能有一个。首选类型名称是 _doc,以便索引 API 具有与 7.0 中相同的路径:PUT {index}/_doc/{id} 和 POST {index}/_doc

    【讨论】:

      猜你喜欢
      • 2019-05-06
      • 2018-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      相关资源
      最近更新 更多