Web / Apache Lucene Interview questions
What is a Lucene Directory?
Directory is Lucene's abstraction over where index files physically live. Both IndexWriter and IndexReader talk to a Directory rather than to the filesystem directly, which is what lets the same indexing code run against different storage backends unchanged.
The most common implementations are:
- FSDirectory - the base class for disk-backed storage, auto-selecting the best implementation for the platform.
- MMapDirectory - uses memory-mapped I/O for fast random access, the default on most 64-bit systems.
- NIOFSDirectory - uses standard Java NIO file channels, useful when memory mapping isn't desirable.
- ByteBuffersDirectory - keeps the entire index in memory, handy for tests or very small indexes.
Swapping Directory implementations is usually a one-line change, which makes it easy to move from an in-memory test index to a production disk-backed one.
More Related questions...