Faster search in Lucene - Is there a way to keep the whole index in RAM?

浪尽此生 提交于 2019-12-17 21:52:36

问题


Is there a way of keeping the index in RAM instead of keeping it on the hard disk?

We want to make searching faster.


回答1:


Is there a way of keeping the index in RAM instead of keeping it on the hard disk?

Using the RAMDirectory class

SampleUsage here

Also from the Lucene FAQs

ImproveSearchingSpeed

Generally for faster indexing performance it's best to flush by RAM usage instead of document count and use as large a RAM buffer as you can.

Also check this question:

EDIT: RE: RamDirectory, As the API says RamDirectory is A memory-resident Directory implementation., it keeps only those index in RAM as specified by directory RAMDirecory

RE:Caching In my knowledge, Lucene caches search results by means of filters pls look @ CachingWrapperFilter and QueryWrapperFilter




回答2:


A RAM disk could be a solution for this. A mini-HOWTO is available at http://www.vanemery.com/Linux/Ramdisk/ramdisk.html. Mount the RAM disk as your index directory, and you should be done.




回答3:


Check out the RAMDirectory documentation. Here's a basic usage example. This will only work if the index is small enough.



来源:https://stackoverflow.com/questions/1293368/faster-search-in-lucene-is-there-a-way-to-keep-the-whole-index-in-ram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!