Elasticsearch primarily stores data on local disk. It employs an inverted index to efficiently support full-text search, with this index stored in files on the disk. Elasticsearch internally utilizes a library named Lucene, which manages the indexing and search operations.
Specifically, Elasticsearch distributes data across multiple nodes to form a cluster. Each index is split into multiple shards, and each shard can have one or more replicas. Shards and replicas are distributed across different nodes in the cluster, ensuring data remains available even if a node fails, with recovery possible through replicas.
For instance, in a specific e-commerce website search engine project, product information might be stored in Elasticsearch. This includes fields like name, description, and price. Each field is indexed and stored on disk for rapid retrieval. To enhance system availability and fault tolerance, multiple replicas for each index can be configured and distributed across different server nodes.
Additionally, Elasticsearch supports storing data in memory, which is beneficial for data requiring quick access, but disk storage remains the primary storage method.