Package org.apache.lucene.store.instantiated
InstantiatedIndex, alternative RAM store for small corpora.
@lucene.experimental
Abstract
Represented as a coupled graph of class instances, this all-in-memory index store implementation delivers search results up to a 100 times faster than the file-centric RAMDirectory at the cost of greater RAM consumption.
API
Just as the default store implementation, InstantiatedIndex comes with an IndexReader and IndexWriter. The latter share many method signatures with the file-centric IndexWriter.
It is also possible to load the content of another index by passing an IndexReader to the InstantiatedIndex constructor.
Performance
At a few thousand ~160 characters long documents InstantiatedIndex outperforms RAMDirectory some 50x, 15x at 100 documents of 2000 characters length, and is linear to RAMDirectory at 10,000 documents of 2000 characters length.
Mileage may vary depending on term saturation.

Populated with a single document InstantiatedIndex is almost, but not quite, as fast as MemoryIndex.
It takes more or less the same time to populate an InstantiatedIndex as it takes to populate a RAMDirectory. Hardly any effort has been put in to optimizing the InstantiatedIndexWriter, only minimizing the amount of time needed to write-lock the index has been considered.
Caveats
- No locks! Consider using InstantiatedIndex as if it was immutable.
- No documents with fields containing readers.
- No field selection when retrieving documents, as all stored field are available in memory.
- Any document returned must cloned if they are to be touched.
- Norms array returned must not be touched.
Use cases
Could replace any small index that could do with greater response time. spell check a priori index, the index of new documents exposed to user search agent queries, to compile classifiers in machine learning environments, etc.
Class diagram

Diagram rendered using UMLet 7.1.
-
Class Summary Class Description InstantiatedDocument A document in the instantiated index object graph, optionally coupled to the vector space view.InstantiatedIndex Deprecated. contrib/instantiated will be removed in 4.0; you can use the memory codec to hold all postings in RAMInstantiatedIndexReader Deprecated. contrib/instantiated will be removed in 4.0; you can use the memory codec to hold all postings in RAMInstantiatedIndexWriter Deprecated. contrib/instantiated will be removed in 4.0; you can use the memory codec to hold all postings in RAMInstantiatedTerm A term in the inverted index, coupled to the documents it occurs in.InstantiatedTermDocs ATermDocs
navigating anInstantiatedIndexReader
.InstantiatedTermDocumentInformation There is one instance of this class per indexed term in a document and it contains the meta data about each occurrence of a term in a document.InstantiatedTermEnum ATermEnum
navigating anInstantiatedIndexReader
.InstantiatedTermFreqVector Vector space view of a document in anInstantiatedIndexReader
.InstantiatedTermPositions ATermPositions
navigating anInstantiatedIndexReader
.InstantiatedTermPositionVector Extended vector space view of a document in anInstantiatedIndexReader
.