簡體   English   中英

如何僅在“內存中”使用彈性搜索索引?

[英]How can I use elastic search indexes exclusively "in-memory"?

我有一個類,用於存儲文檔並使用 elasticsearch 客戶端對其進行索引。 我希望索引僅在內存中,除非明確保存到磁盤。 具體來說:

  • 可以創建索引並搜索它
  • 如果未保存,會話結束時將從磁盤中擦除
  • 如果保存,則持久化到磁盤

然而,Elasticsearch 實際上是一種磁盤服務(將索引直接寫入磁盤,在詢問時刪除)。

有沒有辦法從 Elasticsearch 獲得所需的行為?

該功能很久以前就被刪除了(在 ES 1.7 中)。 可以利用memory存儲將所有內容存儲在內存中而不是文件中。

出於顯而易見的原因,這在 ES 2.0 中棄用並刪除,即在節點損壞的情況下不提供任何彈性。

類似的東西是在啟動時將所有內容預加載到內存中的能力,即使這不能完全滿足您的要求。 隨意擴展為什么你需要這種行為。

您正確地將 Elasticsearch 文檔保存在磁盤中,但數據緩存在 RAM 中,以便我們的 /GET 查詢在搜索時獲得更快的響應,只要您有足夠的內存。

您可以使用以下查詢將索引存儲類型顯式標記為緩存,通過將文件映射到內存來將分片索引存儲在文件系統上(映射到 Lucene MMapDirectory)

curl -XPUT /indexname { "settings": { "index.store.type": "mmapfs" } }

mmapfs

The MMap FS type stores the shard index on the file system (maps to 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 class, be sure you have allowed plenty of virtual address space.

在此處閱讀有關索引存儲類型的更多信息: https : //www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-store.html

此外,如果您正在處理 Elasticsearch 上的大量數據並且最近幾天索引查詢更頻繁,您可以嘗試 ElasticSearch 熱溫節點架構,對於熱節點,您可以將索引存儲設置應用於mmapfs可能僅針對熱節點

更多信息: https : //www.elastic.co/blog/hot-warm-architecture-in-elasticsearch-5-x

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM