前言:本文的目的是為后續磁盤空間利用優化做鋪墊。主要知識點來源於官網文檔
一、doc_value是什么
-
絕大多數的fields在默認情況下是indexed,因此字段數據是可被搜索的。倒排索引中按照一定順序存放着terms供搜索,當命中搜索時,返回包含term的document。
terms 中包含很多term
-
當Sorting、aggregations、scripts access to field這三種情況的時候,我們需要另外的data access模式。這種模式和上述在terms中尋找term並且返回document是不同的
-
Doc values 為on-disk 數據結構,在document索引時被創建。Doc values 存放的values和 _source這個meta-Fields是一致的。支持除了analyzed string 以外的所有類型。
二、doc_value特性
- doc_value 默認情況下是enable的。
- column-oriented 存放field,以便sort、aggregate、access the field from a script
- disable doc_value:
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"mystring": {
"type": "keyword",
"doc_values": false
}
}
}
}
}
三、disable doc_value會怎樣
- 消極影響:sort、aggregate、access the field from script將會無法使用
- 積極影響:節省磁盤空間