2013-08-28 19:24:34 -04:00
|
|
|
[[index-modules-store]]
|
|
|
|
== Store
|
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
The store module allows you to control how index data is stored and accessed on disk.
|
2015-01-14 05:35:09 -05:00
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[file-system]]
|
2014-06-12 07:56:06 -04:00
|
|
|
=== File system storage types
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2016-06-15 03:07:18 -04:00
|
|
|
There are different file system implementations or _storage types_. By default,
|
2017-11-29 03:44:25 -05:00
|
|
|
Elasticsearch will pick the best implementation based on the operating
|
2016-06-15 03:07:18 -04:00
|
|
|
environment.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2014-06-12 07:56:06 -04:00
|
|
|
This can be overridden for all indices by adding this to the
|
|
|
|
`config/elasticsearch.yml` file:
|
|
|
|
|
|
|
|
[source,yaml]
|
|
|
|
---------------------------------
|
|
|
|
index.store.type: niofs
|
|
|
|
---------------------------------
|
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
It is a _static_ setting that can be set on a per-index basis at index
|
|
|
|
creation time:
|
2014-06-12 07:56:06 -04:00
|
|
|
|
2015-07-14 12:14:09 -04:00
|
|
|
[source,js]
|
2014-06-12 07:56:06 -04:00
|
|
|
---------------------------------
|
2019-01-14 16:08:01 -05:00
|
|
|
PUT /my_index?include_type_name=true
|
2015-06-22 17:49:45 -04:00
|
|
|
{
|
|
|
|
"settings": {
|
|
|
|
"index.store.type": "niofs"
|
|
|
|
}
|
|
|
|
}
|
2014-06-12 07:56:06 -04:00
|
|
|
---------------------------------
|
2017-08-30 03:30:36 -04:00
|
|
|
// CONSOLE
|
2014-06-12 07:56:06 -04:00
|
|
|
|
2017-07-18 08:06:22 -04:00
|
|
|
WARNING: This is an expert-only setting and may be removed in the future.
|
2015-06-22 17:49:45 -04:00
|
|
|
|
2014-06-12 07:56:06 -04:00
|
|
|
The following sections lists all the different storage types supported.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2016-06-15 03:07:18 -04:00
|
|
|
`fs`::
|
|
|
|
|
|
|
|
Default file system implementation. This will pick the best implementation
|
2019-01-02 04:10:32 -05:00
|
|
|
depending on the operating environment, which is currently `hybridfs` on all
|
2017-07-31 03:55:09 -04:00
|
|
|
supported systems but is subject to change.
|
2016-06-15 03:07:18 -04:00
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
[[simplefs]]`simplefs`::
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
The Simple FS type is a straightforward implementation of file system
|
2013-08-28 19:24:34 -04:00
|
|
|
storage (maps to Lucene `SimpleFsDirectory`) using a random access file.
|
|
|
|
This implementation has poor concurrent performance (multiple threads
|
|
|
|
will bottleneck). It is usually better to use the `niofs` when you need
|
|
|
|
index persistence.
|
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
[[niofs]]`niofs`::
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
The NIO FS type stores the shard index on the file system (maps to
|
2013-08-28 19:24:34 -04:00
|
|
|
Lucene `NIOFSDirectory`) using NIO. It allows multiple threads to read
|
|
|
|
from the same file concurrently. It is not recommended on Windows
|
|
|
|
because of a bug in the SUN Java implementation.
|
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
[[mmapfs]]`mmapfs`::
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
The MMap FS type stores the shard index on the file system (maps to
|
2013-08-28 19:24:34 -04:00
|
|
|
Lucene `MMapDirectory`) by mapping a file into memory (mmap). Memory
|
|
|
|
mapping uses up a portion of the virtual memory address space in your
|
|
|
|
process equal to the size of the file being mapped. Before using this
|
2015-06-22 17:49:45 -04:00
|
|
|
class, be sure you have allowed plenty of
|
|
|
|
<<vm-max-map-count,virtual address space>>.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-01-02 04:10:32 -05:00
|
|
|
[[hybridfs]]`hybridfs`::
|
|
|
|
|
|
|
|
The `hybridfs` type is a hybrid of `niofs` and `mmapfs`, which chooses the best
|
|
|
|
file system type for each type of file based on the read access pattern.
|
|
|
|
Currently only the Lucene term dictionary, norms and doc values files are
|
|
|
|
memory mapped. All other files are opened using Lucene `NIOFSDirectory`.
|
|
|
|
Similarly to `mmapfs` be sure you have allowed plenty of
|
|
|
|
<<vm-max-map-count,virtual address space>>.
|
|
|
|
|
2019-01-03 01:10:34 -05:00
|
|
|
[[allow-mmap]]
|
2019-01-02 04:10:32 -05:00
|
|
|
You can restrict the use of the `mmapfs` and the related `hybridfs` store type
|
2019-01-03 01:10:34 -05:00
|
|
|
via the setting `node.store.allow_mmap`. This is a boolean setting indicating
|
2019-01-02 04:10:32 -05:00
|
|
|
whether or not memory-mapping is allowed. The default is to allow it. This
|
|
|
|
setting is useful, for example, if you are in an environment where you can not
|
|
|
|
control the ability to create a lot of memory maps so you need disable the
|
|
|
|
ability to use memory-mapping.
|
2018-08-21 11:02:25 -04:00
|
|
|
|
2016-06-15 03:07:18 -04:00
|
|
|
=== Pre-loading data into the file system cache
|
|
|
|
|
2017-07-18 08:06:22 -04:00
|
|
|
NOTE: This is an expert setting, the details of which may change in the future.
|
2016-06-15 03:07:18 -04:00
|
|
|
|
2017-11-29 03:44:25 -05:00
|
|
|
By default, Elasticsearch completely relies on the operating system file system
|
2016-06-15 03:07:18 -04:00
|
|
|
cache for caching I/O operations. It is possible to set `index.store.preload`
|
|
|
|
in order to tell the operating system to load the content of hot index
|
|
|
|
files into memory upon opening. This setting accept a comma-separated list of
|
2016-10-10 16:51:47 -04:00
|
|
|
files extensions: all files whose extension is in the list will be pre-loaded
|
2016-06-15 03:07:18 -04:00
|
|
|
upon opening. This can be useful to improve search performance of an index,
|
|
|
|
especially when the host operating system is restarted, since this causes the
|
|
|
|
file system cache to be trashed. However note that this may slow down the
|
|
|
|
opening of indices, as they will only become available after data have been
|
|
|
|
loaded into physical memory.
|
|
|
|
|
|
|
|
This setting is best-effort only and may not work at all depending on the store
|
|
|
|
type and host operating system.
|
|
|
|
|
2016-11-05 09:57:22 -04:00
|
|
|
The `index.store.preload` is a static setting that can either be set in the
|
2016-06-15 03:07:18 -04:00
|
|
|
`config/elasticsearch.yml`:
|
|
|
|
|
|
|
|
[source,yaml]
|
|
|
|
---------------------------------
|
2016-11-05 09:57:22 -04:00
|
|
|
index.store.preload: ["nvd", "dvd"]
|
2016-06-15 03:07:18 -04:00
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
or in the index settings at index creation time:
|
2014-06-26 16:46:21 -04:00
|
|
|
|
2016-06-15 03:07:18 -04:00
|
|
|
[source,js]
|
|
|
|
---------------------------------
|
2019-01-14 16:08:01 -05:00
|
|
|
PUT /my_index?include_type_name=true
|
2016-06-15 03:07:18 -04:00
|
|
|
{
|
|
|
|
"settings": {
|
2016-11-05 09:57:22 -04:00
|
|
|
"index.store.preload": ["nvd", "dvd"]
|
2016-06-15 03:07:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
---------------------------------
|
2017-08-30 03:30:36 -04:00
|
|
|
// CONSOLE
|
2014-06-26 16:46:21 -04:00
|
|
|
|
2016-06-15 03:07:18 -04:00
|
|
|
The default value is the empty array, which means that nothing will be loaded
|
|
|
|
into the file-system cache eagerly. For indices that are actively searched,
|
|
|
|
you might want to set it to `["nvd", "dvd"]`, which will cause norms and doc
|
|
|
|
values to be loaded eagerly into physical memory. These are the two first
|
2017-11-29 03:44:25 -05:00
|
|
|
extensions to look at since Elasticsearch performs random access on them.
|
2016-06-15 03:07:18 -04:00
|
|
|
|
|
|
|
A wildcard can be used in order to indicate that all files should be preloaded:
|
2016-11-05 09:57:22 -04:00
|
|
|
`index.store.preload: ["*"]`. Note however that it is generally not useful to
|
2016-06-15 03:07:18 -04:00
|
|
|
load all files into memory, in particular those for stored fields and term
|
|
|
|
vectors, so a better option might be to set it to
|
|
|
|
`["nvd", "dvd", "tim", "doc", "dim"]`, which will preload norms, doc values,
|
|
|
|
terms dictionaries, postings lists and points, which are the most important
|
|
|
|
parts of the index for search and aggregations.
|
|
|
|
|
|
|
|
Note that this setting can be dangerous on indices that are larger than the size
|
|
|
|
of the main memory of the host, as it would cause the filesystem cache to be
|
|
|
|
trashed upon reopens after large merges, which would make indexing and searching
|
|
|
|
_slower_.
|