Elasticsearch允许你存储_type与一起_index.我想知道我是否应该提供自己的,_id如果它在整个索引中是独一无二的吗?
它应该是独一无二的
PUT so
PUT /so/t1/1
{}
PUT /so/t2/1
{}
GET /so/_search
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "so",
"_type": "t2",
"_id": "1",
"_score": 1,
"_source": {}
},
{
"_index": "so",
"_type": "t1",
"_id": "1",
"_score": 1,
"_source": {}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
原因是:你不会通过索引知道doctype来获取文档,并且使用索引范围的查询查询ES将返回包括其类型和索引的文档.
| 归档时间: |
|
| 查看次数: |
5484 次 |
| 最近记录: |