store.asciidoc 5.4 KB

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