store.asciidoc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. [[index-modules-store]]
  2. == Store
  3. The store module allows you to control how index data is stored and accessed on disk.
  4. NOTE: This is a low-level setting. Some store implementations have poor
  5. concurrency or disable optimizations for heap memory usage. We recommend
  6. sticking to the defaults.
  7. [discrete]
  8. [[file-system]]
  9. === File system storage types
  10. There are different file system implementations or _storage types_. By default,
  11. Elasticsearch will pick the best implementation based on the operating
  12. environment.
  13. The storage type can also be explicitly set for all indices by configuring the
  14. store type in the `config/elasticsearch.yml` file:
  15. [source,yaml]
  16. ---------------------------------
  17. index.store.type: hybridfs
  18. ---------------------------------
  19. It is a _static_ setting that can be set on a per-index basis at index
  20. creation time:
  21. [source,console]
  22. ---------------------------------
  23. PUT /my-index-000001
  24. {
  25. "settings": {
  26. "index.store.type": "hybridfs"
  27. }
  28. }
  29. ---------------------------------
  30. WARNING: This is an expert-only setting and may be removed in the future.
  31. The following sections lists all the different storage types supported.
  32. `fs`::
  33. Default file system implementation. This will pick the best implementation
  34. depending on the operating environment, which is currently `hybridfs` on all
  35. supported systems but is subject to change.
  36. [[simplefs]]`simplefs`::
  37. deprecated::[7.15,"simplefs is deprecated and will be removed in 8.0. Use niofs or other file systems instead. Elasticsearch 7.15 or later uses niofs for the simplefs store type as it offers superior or equivalent performance to simplefs."]
  38. The Simple FS type is a straightforward implementation of file system
  39. storage (maps to Lucene `SimpleFsDirectory`) using a random access file.
  40. This implementation has poor concurrent performance (multiple threads
  41. will bottleneck) and disables some optimizations for heap memory usage.
  42. [[niofs]]`niofs`::
  43. The NIO FS type stores the shard index on the file system (maps to
  44. Lucene `NIOFSDirectory`) using NIO. It allows multiple threads to read
  45. from the same file concurrently. It is not recommended on Windows
  46. because of a bug in the SUN Java implementation and disables some
  47. optimizations for heap memory usage.
  48. [[mmapfs]]`mmapfs`::
  49. The MMap FS type stores the shard index on the file system (maps to
  50. Lucene `MMapDirectory`) by mapping a file into memory (mmap). Memory
  51. mapping uses up a portion of the virtual memory address space in your
  52. process equal to the size of the file being mapped. Before using this
  53. class, be sure you have allowed plenty of
  54. <<vm-max-map-count,virtual address space>>.
  55. [[hybridfs]]`hybridfs`::
  56. The `hybridfs` type is a hybrid of `niofs` and `mmapfs`, which chooses the best
  57. file system type for each type of file based on the read access pattern.
  58. Currently only the Lucene term dictionary, norms and doc values files are
  59. memory mapped. All other files are opened using Lucene `NIOFSDirectory`.
  60. Similarly to `mmapfs` be sure you have allowed plenty of
  61. <<vm-max-map-count,virtual address space>>.
  62. [[allow-mmap]]
  63. You can restrict the use of the `mmapfs` and the related `hybridfs` store type
  64. via the setting `node.store.allow_mmap`. This is a boolean setting indicating
  65. whether or not memory-mapping is allowed. The default is to allow it. This
  66. setting is useful, for example, if you are in an environment where you can not
  67. control the ability to create a lot of memory maps so you need disable the
  68. ability to use memory-mapping.
  69. [[preload-data-to-file-system-cache]]
  70. === Preloading data into the file system cache
  71. NOTE: This is an expert setting, the details of which may change in the future.
  72. By default, Elasticsearch completely relies on the operating system file system
  73. cache for caching I/O operations. It is possible to set `index.store.preload`
  74. in order to tell the operating system to load the content of hot index
  75. files into memory upon opening. This setting accept a comma-separated list of
  76. files extensions: all files whose extension is in the list will be pre-loaded
  77. upon opening. This can be useful to improve search performance of an index,
  78. especially when the host operating system is restarted, since this causes the
  79. file system cache to be trashed. However note that this may slow down the
  80. opening of indices, as they will only become available after data have been
  81. loaded into physical memory.
  82. This setting is best-effort only and may not work at all depending on the store
  83. type and host operating system.
  84. The `index.store.preload` is a static setting that can either be set in the
  85. `config/elasticsearch.yml`:
  86. [source,yaml]
  87. ---------------------------------
  88. index.store.preload: ["nvd", "dvd"]
  89. ---------------------------------
  90. or in the index settings at index creation time:
  91. [source,console]
  92. ---------------------------------
  93. PUT /my-index-000001
  94. {
  95. "settings": {
  96. "index.store.preload": ["nvd", "dvd"]
  97. }
  98. }
  99. ---------------------------------
  100. The default value is the empty array, which means that nothing will be loaded
  101. into the file-system cache eagerly. For indices that are actively searched,
  102. you might want to set it to `["nvd", "dvd"]`, which will cause norms and doc
  103. values to be loaded eagerly into physical memory. These are the two first
  104. extensions to look at since Elasticsearch performs random access on them.
  105. A wildcard can be used in order to indicate that all files should be preloaded:
  106. `index.store.preload: ["*"]`. Note however that it is generally not useful to
  107. load all files into memory, in particular those for stored fields and term
  108. vectors, so a better option might be to set it to
  109. `["nvd", "dvd", "tim", "doc", "dim"]`, which will preload norms, doc values,
  110. terms dictionaries, postings lists and points, which are the most important
  111. parts of the index for search and aggregations.
  112. Note that this setting can be dangerous on indices that are larger than the size
  113. of the main memory of the host, as it would cause the filesystem cache to be
  114. trashed upon reopens after large merges, which would make indexing and searching
  115. _slower_.