在弹性搜索中的索引下为文档类型创建映射时出错
error while creating a mapping for document type under an index in elastic search
您好,我正在尝试使用 kibana 控制台在弹性搜索中的索引 "ecommerce" 下创建文档类型 "product"。
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 版中创建类型,并且它已被弃用。您从 link
中获得了以下可用信息
Specifying types in requests is deprecated. For instance, indexing a
document no longer requires a document type. The new index APIs are
PUT {index}/_doc/{id} in case of explicit ids and POST {index}/_doc
for auto-generated ids. Note that in 7.0, _doc is a permanent part of
the path, and represents the endpoint name rather than the document
type.
我建议遵循上述任何方法 here
基本上要么为每个文档类型创建一个新索引,要么只添加一个新索引自定义类型字段。
下面是您的映射方式:
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"
}
}
}
}
您好,我正在尝试使用 kibana 控制台在弹性搜索中的索引 "ecommerce" 下创建文档类型 "product"。
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 版中创建类型,并且它已被弃用。您从 link
中获得了以下可用信息Specifying types in requests is deprecated. For instance, indexing a document no longer requires a document type. The new index APIs are PUT {index}/_doc/{id} in case of explicit ids and POST {index}/_doc for auto-generated ids. Note that in 7.0, _doc is a permanent part of the path, and represents the endpoint name rather than the document type.
我建议遵循上述任何方法 here
基本上要么为每个文档类型创建一个新索引,要么只添加一个新索引自定义类型字段。
下面是您的映射方式:
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"
}
}
}
}