我是弹性6.8和路由似乎不工作。我用的例子,
PUT my_index/_doc/2?routing="user1"
{
"title": "This is a document"
}
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "2",
"_version" : 2,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 1,
"_primary_term" : 1
}
关于申请 GET
查询
GET my_index/_doc/2?routing="user1"
没有结果。看起来很奇怪,我是不是遗漏了什么?
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "2",
"found" : false
}
更新#1
以下api导致错误(取自文档)
PUT my_index/_doc/1?routing=user1&refresh=true
{
"title": "This is a document"
}
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Unknown value for refresh: [true ]."
}
],
"type": "illegal_argument_exception",
"reason": "Unknown value for refresh: [true ]."
},
"status": 400
}
1条答案
按热度按时间33qvvth11#
出现以下错误是因为在结尾处添加了1或2个空格字符
refresh=true
在PUT my_index/_doc/1?routing=user1&refresh=true
```{
"type": "illegal_argument_exception",
"reason": "Unknown value for refresh: [true ]."
}
if ("".equals(value)) {
// Empty string is IMMEDIATE because that makes "POST /test/test/1?refresh" perform
// a refresh which reads well and is what folks are used to.
return IMMEDIATE;
}
throw new IllegalArgumentException("Unknown value for refresh: [" + value + "].");
PUT http://localhost:9200/{{index-name}}/_doc/1?routing=user1&refresh=true
{
"name":"multi grain bread"
}
{
"_index": "64762507",
"_type": "_doc",
"_id": "1",
"_version": 1,
"result": "created",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
{
"_index": "64762507",
"_type": "_doc",
"_id": "1",
"_version": 1,
"_seq_no": 0,
"_primary_term": 1,
"_routing": "user1",
"found": true,
"_source": {
"name": "multi grain bread"
}
}