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

后端 未结 3 894
谎友^
谎友^ 2020-12-13 01:16

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

We want to make searching faster.

3条回答
  •  长情又很酷
    2020-12-13 01:33

    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

提交回复
热议问题