elasticsearch 在弹性搜索中为索引下的文档类型创建映射时出错
您好,我正在尝试使用kibana控制台在弹性搜索中的索引电子商务下创建文档类型产品elasticsearch 在弹性搜索中为索引下的文档类型创建映射时出错,elasticsearch,lucene,elasticsearch,Lucene,您好,我正在尝试使用kibana控制台在弹性搜索中的索引电子商务下创建文档类型产品 PUT /ecommerce { "mappings": { "product": { "properties": { "name": { "type": "string" }, "price": { "type": "double" }, "description":
PUT /ecommerce
{
"mappings": {
"product": {
"properties": {
"name": {
"type": "string"
},
"price": {
"type": "double"
},
"description": {
"type": "string"
},
"status": {
"type": "string"
},
"quantity": {
"type": "integer"
},
"categories": {
"type": "nested",
"properties": {
"name": {
"type": "string"
}
}
},
"tags": {
"type": "string"
}
}
}
}
}
当我运行此请求时,我得到以下错误
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [product : {properties={quantity={type=integer}, price={type=double}, name={type=string}, description={type=string}, categories={type=nested, properties={name={type=string}}}, status={type=string}, tags={type=string}}}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [product : {properties={quantity={type=integer}, price={type=double}, name={type=string}, description={type=string}, categories={type=nested, properties={name={type=string}}}, status={type=string}, tags={type=string}}}]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [product : {properties={quantity={type=integer}, price={type=double}, name={type=string}, description={type=string}, categories={type=nested, properties={name={type=string}}}, status={type=string}, tags={type=string}}}]"
}
},
"status": 400
}
知道我的put请求有什么问题吗。
非常感谢您无法在ES post 7.0版中创建类型,并且它已被弃用。您可以从本网站获得以下可用信息 不推荐在请求中指定类型。例如,索引 文档不再需要文档类型。新的索引API是 将{index}/_-doc/{id}放在显式id和POST{index}/_-doc的情况下 用于自动生成的ID。注意,在7.0中,_doc是 路径,并表示端点名称而不是文档 类型 我建议遵循上述任何一种方法 基本上,可以为每个文档类型创建一个新索引,也可以只添加一个新的自定义类型字段 以下是您的映射方式:
POST <your_new_index_name>
{
"mappings":{
"properties":{
"name":{
"type":"string"
},
"price":{
"type":"double"
},
"description":{
"type":"string"
},
"status":{
"type":"string"
},
"quantity":{
"type":"integer"
},
"categories":{
"type":"nested",
"properties":{
"name":{
"type":"string"
}
}
},
"tags":{
"type":"string"
}
}
}
}
基本上,如果您尝试接收任何新文档,则必须使用以下端点:
PUT <your_new_index_name>/_doc/1
{
"myfield":"myvalue"
}
希望这有帮助 我重写了我的查询,如下所示,它可以正常工作
PUT /ecommerce
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"price": {
"type": "double"
},
"description": {
"type": "text"
},
"status": {
"type": "text"
},
"quantity": {
"type": "integer"
},
"categories": {
"type": "nested",
"properties": {
"name": {
"type": "text"
}
}
},
"tags": {
"type": "text"
}
}
}
}
这也可能导致:我花了一些时间意识到我拼错了端点。