如何在 Elasticsearch 中创建多类型索引?
How to create a mutlitype index in Elasticsearch?
Elasticsearch文档中有好几页提到了如何查询多类型索引。
但是我一开始就创建失败了。
这是我的最小示例(在 Elasticsearch 6.x 服务器上):
PUT /myindex
{
"settings" : {
"number_of_shards" : 1
}
}
PUT /myindex/people/123
{
"first name": "John",
"last name": "Doe"
}
PUT /myindex/dog/456
{
"name": "Rex"
}
索引创建和拳头插入做得很好,但在 dog 类型插入尝试中:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [myindex] as the final mapping would have more than 1 type: [people, dog]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [myindex] as the final mapping would have more than 1 type: [people, dog]"
},
"status": 400
}
但这正是我想要做的,伙计!我的索引中有 "more than 1 type"。
你知道我必须改变我的电话才能实现这一目标吗?
非常感谢。
从 Elastic 6.0.0 开始不支持多种映射类型。有关详细信息,请参阅 breaking changes。
您仍然可以通过实现自己的自定义类型字段来有效地使用多种类型。
例如:
{
"mappings": {
"doc": {
"properties": {
"type": {
"type": "keyword"
},
"first_name": {
"type": "text"
},
"last_name": {
"type": "text"
}
}
}
}
}
这在 removal of types 中有描述。
Elasticsearch文档中有好几页提到了如何查询多类型索引。 但是我一开始就创建失败了。
这是我的最小示例(在 Elasticsearch 6.x 服务器上):
PUT /myindex
{
"settings" : {
"number_of_shards" : 1
}
}
PUT /myindex/people/123
{
"first name": "John",
"last name": "Doe"
}
PUT /myindex/dog/456
{
"name": "Rex"
}
索引创建和拳头插入做得很好,但在 dog 类型插入尝试中:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [myindex] as the final mapping would have more than 1 type: [people, dog]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [myindex] as the final mapping would have more than 1 type: [people, dog]"
},
"status": 400
}
但这正是我想要做的,伙计!我的索引中有 "more than 1 type"。
你知道我必须改变我的电话才能实现这一目标吗?
非常感谢。
从 Elastic 6.0.0 开始不支持多种映射类型。有关详细信息,请参阅 breaking changes。
您仍然可以通过实现自己的自定义类型字段来有效地使用多种类型。
例如:
{
"mappings": {
"doc": {
"properties": {
"type": {
"type": "keyword"
},
"first_name": {
"type": "text"
},
"last_name": {
"type": "text"
}
}
}
}
}
这在 removal of types 中有描述。