本文介绍了无法创建两个类型到相同的索引 elasticsearch &基巴纳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 elasticsearch 和 kibana 的新手

I'm new in elasticsearch and kibana

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

I'm doing some exercices with elasticsearch (create index,types and documents..)

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

I created an index 'business' with type 'building'

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

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

it works funny but when I tried to create another type like this

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 版本 6,并且从该版本开始,ES 不允许您创建 在任何给定索引中都超过一种类型.

You're probably running Elasticsearch version 6 and as of that version ES doesn't allow you to create more than one type in any given index.

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

You need to store each of your document type inside a dedicated index, e.g.

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"
}

这篇关于无法创建两个类型到相同的索引 elasticsearch &基巴纳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 16:09