Elasticsearch 简明教程

Elasticsearch - Frozen Indices

频繁搜索的索引保存在内存中,因为重建它们需要时间,并且有助于高效搜索。另一方面,可能有一些我们很少访问的索引。这些索引不需要占用内存,并且可以在需要时重新构建。这种索引被称为冻结索引。

The indices that are searched frequently are held in memory because it takes time to rebuild them and help in an efficient search. On the other hand, there may be indices which we rarely access. Those indices need not occupy the memory and can be re-build when they are needed. Such indices are known as frozen indices.

Elasticsearch 在每次搜索冻结索引的每个分片时都会构建分片的瞬态数据结构,并在搜索完成后立即丢弃这些数据结构。由于 Elasticsearch 不在内存中维护这些瞬态数据结构,因此冻结索引消耗的堆比普通索引少得多。这允许比其他可能的情况更高的磁盘到堆的比率。

Elasticsearch builds the transient data structures of each shard of a frozen index each time that shard is searched and discards these data structures as soon as the search is complete. Because Elasticsearch does not maintain these transient data structures in memory, frozen indices consume much less heap than the normal indices. This allows for a much higher disk-to-heap ratio than would otherwise be possible.

Example for Freezing and Unfreezing

以下示例冻结和解冻索引 -

The following example freezes and unfreezes an index −

POST /index_name/_freeze
POST /index_name/_unfreeze

预期对冻结索引的搜索将缓慢执行。冻结索引不适用于高搜索负载。冻结索引的搜索可能需要几秒或几分钟才能完成,即使在索引未冻结时,相同的搜索可以在几毫秒内完成。

Searches on frozen indices are expected to execute slowly. Frozen indices are not intended for high search load. It is possible that a search of a frozen index may take seconds or minutes to complete, even if the same searches completed in milliseconds when the indices were not frozen.

Searching a Frozen Index

每个节点同时加载的冻结索引数量受 search_throttled 线程池中线程数量的限制,默认值为 1。要包含冻结索引,必须使用查询参数执行搜索请求 - ignore_throttled=false。

The number of concurrently loaded frozen indices per node is limited by the number of threads in the search_throttled threadpool, which is 1 by default. To include frozen indices, a search request must be executed with the query parameter − ignore_throttled=false.

GET /index_name/_search?q=user:tpoint&ignore_throttled=false

Monitoring Frozen Indices

冻结索引是使用搜索限制和内存高效分片实现的普通索引。

Frozen indices are ordinary indices that use search throttling and a memory efficient shard implementation.

GET /_cat/indices/index_name?v&h=i,sth