Is it possible to say use 16GB MAX RAM and if more data comes to indexes shuffle between RAM and secondary storage?
What I got for now is there is a possibility that if somehow all documents being searched then all documents will ultimately stay in heap forever... is it right assumption?
That's already how Elasticsearch works. Heap is just allocated for current actions, RAM is just for buffering, indices are stored in secondary storages (files) on distributed machines.
RAM / memory size does not determine maximum index size. There is no relation between the two.
If you index documents, they are flushed to disk automatically by Elasticsearch. This is controlled by document count, document size, or a given interval (e.g. every 5 seconds).
If you search documents, Elasticsearch will do the heavy task of deciding how to use RAM for you. Only relevant files are buffered in RAM and only relevant search results occupy the heap. The exact procedure depends on the query type, the index configuration, and some other things (like caching or concurrency).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.