1. doc_values(文档值)

原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/5.3/doc-values.html

译文链接 : http://www.apache.wiki/pages/createpage-entervariables.action?templateId=4816898&spaceKey=Elasticsearch&title=&newSpaceKey=Elasticsearch&fromPageId=9405287

贡献者 : 程威ApacheCNApache中文网

在默认情况下许多字段都是 indexed(被索引的),这使得它们可以被搜索.反向索引允许查询通过唯一性排序的 term(词根)列表来查询 term(词根),并且可以立即访问包含该 term(词根)的文档.

脚本中的排序,聚合和对字段值的访问需要一种不同的数据访问模式.我们不需要先查找 term(词根),再寻找对应的 documents(文档),而是可以先查找 document(文档),再查找它在一个字段中的 terms(词根).

Doc values 是在 document 索引时间内构建在磁盘上的数据结构,这使得上面所说的数据访问模式成为可能.它们存储与 _source 相同的值,但是以列为主的方式存储.这使得排序和聚合效率更高.几乎所有字段类型都支持 Doc values ,除了 the notable exception of analyzed string fields.

默认情况下,支持 doc values 的所有字段都是开启的.如果你确定不需要在字段上进行排序和聚合,活从脚本中访问字段值,则可以禁用 doc values 来节省磁盘空间.

 curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "my_type": {
      "properties": {
        "status_code": { # 1
          "type":       "keyword"
        },
        "session_id": { # 2
          "type":       "keyword",
          "doc_values": false
        }
      }
    }
  }
}
'

| 1 | status_code 默认开启 doc_values | | 2 | session_id 关闭 doc_values,但是仍然可以被查询. |

Copyright © Kilvn 2021. all right reserved,powered by Gitbook最后更新时间: 2021-06-08 20:22:42

results matching ""

    No results matching ""