以下是索引 index_new
的映射{
"mappings": {
"_doc": {
"properties": {
"title": {
"type": "text"
},
"name": {
"type": "text"
},
"age": {
"type": "integer"
},
"price_amount": {
"properties": {
"val": {
"type": "scaled_float",
"scaling_factor": 100
}
}
}
}
}
}
}
将数据添加到该索引中
curl -X POST \
http://localhost:9200/new_index1/1 \
-H 'Content-Type: application/json' \
-d '{
"title": "new data for index",
"name": "balakarthik",
"age": 24,
"price_amount": {
"val": 1005,
"scaling_factor": 100
}
}'
这将返回错误
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Field [val] misses required parameter [scaling_factor]"
}
},
"status": 400
}
由于映射中已经提供了比例因子,因此我们需要在每个请求中发送比例因子,如果是,那么我们如何在每个请求中发送比例因子。
scaled_float的定义可用here
答案 0 :(得分:0)
我遇到此错误,但通过更改URL克服了该错误。
您的PUT应该转到:http://localhost:9200/new_index1/_doc/1
此外,您应该将输入数据更改为仅指定值。像这样:
{
"title": "new data for index",
"name": "balakarthik",
"age": 24,
"price_amount": 10.05
}