Lucene does not offer an out-of-the-box UPDATE, so we have to manually DELETE then CREATE, which is problematic because Lucene DELETE can be extremely slow (plus this is not atomic).
Lucene does not offer an out-of-the-box UPDATE, so we have to manually DELETE then CREATE, which is problematic because Lucene DELETE can be extremely slow (plus this is not atomic).
It is a **lot** more efficient to do this in batch: expect 10,000 deletes to take about 1 second and inserts about 100ms. Each call to this method constitutes a batch UPDATE operation.
Lightweight convenience wrapper over Lucene that does some sanity checking, sets up per-field
Analyzer
s and gives access to CRUD-like operations. Callers are expected to perform their own marshalling and unmarshalling for Lucene'sQuery
andDocument
types.This class is thread safe. Only one instance is allowed **on the operating system** (not just the JVM) for the same path. Lucene manages a file lock to mitigate the risk of this happening.
Technical note: Lucene is an excellent INDEX store, but is not a database. Prefer using the DatabaseProvider where possible and only fall back to using the index when SQL doesn't cut it. Excellent examples of using an index are for creating multiple representations of the same column, or for allowing allow/deny filtering rules based on tags.