我是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
}
答案 0 :(得分:38)
您可能正在运行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"
}
答案 1 :(得分:1)
有关更多信息,请参见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