Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

We want to make searching faster.

like image 848
elif Avatar asked Aug 18 '09 11:08

elif


People also ask

What does Lucene index do?

A Lucene Index Is an Inverted Index An index may store a heterogeneous set of documents, with any number of different fields that may vary by a document in arbitrary ways. Lucene indexes terms, which means that Lucene search searches over terms. A term combines a field name with a token.


2 Answers

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

like image 200
Narayan Avatar answered Sep 18 '22 06:09

Narayan


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.

like image 43
pompo Avatar answered Sep 22 '22 06:09

pompo