虽然知道_source field一般不要随便调整,但没专门去看具体原因,正好有人分析了,这里就直接转载过来。
_source是什么
_source field是我们在PUT数据时候的json body:
PUT store_index/my_type/1
{
"title": "Some short title",
"date": "2015-01-01",
"content": "A very long content field..."
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "store_index",
"_type": "my_type",
"_id": "1",
"_score": 1,
"_source": {
"title": "Some short title",
"date": "2015-01-01",
"content": "A very long content field..."
}
}
]
}
}
_source disable的方法
PUT tweets
{
"mappings": {
"tweet": {
"_source": {
"enabled": false
}
}
}
}
disable掉_source会怎样
- 消极影响:(总的来说后果比较严重最好不要disable)
- update、update_by_query、reindex API将不再可用
- highlighting将会受影响(?)
- elasticsearch索引的reindex、修改mapping、改变分词、更新索引等都会不可用
- 通过查看原始文档来调试查询或者聚合的功能将不可用
- elasticsearch失去自动修复index损坏的能力
- 积极影响:节省磁盘空间
TIP:万不得已,不要disable _source。如果磁盘实在不够了,可以先考虑增加compression level