SearchBackend is the Implementor.
SearchContext decouples the GUI's view of search from the concrete backend.
Callers always work against this abstraction; the backend reference may be
swapped live (e.g. when the user toggles the "use Postgres-backed search"
preference). When the backing preference changes, the context closes the
previous backend and instantiates a new one via the supplier passed in at
construction time. Switching to the SQL backend triggers a full re-index
because the org. constructor
indexes all current entries on creation.
All methods are synchronized so concurrent search calls and a live swap do not interleave. The lock is held for the duration of each forwarded call.
| Modifier and Type | Field and Description |
|---|---|
| private SearchBackend | |
| private final Supplier | |
| private static final Logger | |
| private final com. | |
| private final Supplier | |
| private final BooleanProperty |
| Access | Constructor and Description |
|---|---|
| public | SearchContext(BooleanProperty usePostgresProperty, Supplier<SearchBackend> sqlFactory, Supplier<SearchBackend> inMemoryFactory)
|
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addToIndex(List<BibEntry> entries)
Implements org. Indexing lifecycle. |
| private SearchBackend | |
| public synchronized void | close()
Implements org. Release backend resources (DB connections, Lucene index handles, …). |
| public synchronized boolean | isEntryMatched(BibEntry entry, SearchQuery query)
Implements org. Test a single entry against the query without re-running a full library search. |
| public synchronized void | rebuildFullTextIndex()
Implements org. Re-index linked-file fulltext from scratch. |
| public synchronized void | removeFromIndex(List<BibEntry> entries)
Implements org.
|
| public synchronized SearchResults | search(SearchQuery query)
Implements org. Run the query against this backend. |
| private synchronized void | |
| public synchronized void |
| backend | back to summary |
|---|---|
| private SearchBackend backend | |
| inMemoryFactory | back to summary |
|---|---|
| private final Supplier<SearchBackend> inMemoryFactory | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| preferenceSubscription | back to summary |
|---|---|
| private final com. | |
| sqlFactory | back to summary |
|---|---|
| private final Supplier<SearchBackend> sqlFactory | |
| usePostgresProperty | back to summary |
|---|---|
| private final BooleanProperty usePostgresProperty | |
| SearchContext | back to summary |
|---|---|
| public SearchContext(BooleanProperty usePostgresProperty, Supplier<SearchBackend> sqlFactory, Supplier<SearchBackend> inMemoryFactory) | |
| addToIndex | back to summary |
|---|---|
| public synchronized void addToIndex(List<BibEntry> entries) Implements org. Doc from org. Indexing lifecycle. Backends without an index (e.g. in-memory) implement these as no-ops.
| |
| buildBackend | back to summary |
|---|---|
| private SearchBackend buildBackend() | |
| close | back to summary |
|---|---|
| public synchronized void close() Implements org. Doc from org. Release backend resources (DB connections, Lucene index handles, …). Idempotent.
| |
| isEntryMatched | back to summary |
|---|---|
| public synchronized boolean isEntryMatched(BibEntry entry, SearchQuery query) Implements org. Doc from org. Test a single entry against the query without re-running a full library search.
| |
| rebuildFullTextIndex | back to summary |
|---|---|
| public synchronized void rebuildFullTextIndex() Implements org. Doc from org. Re-index linked-file fulltext from scratch. Backends without a fulltext index implement as a no-op.
| |
| removeFromIndex | back to summary |
|---|---|
| public synchronized void removeFromIndex(List<BibEntry> entries) Implements org.
| |
| search | back to summary |
|---|---|
| public synchronized SearchResults search(SearchQuery query) Implements org. Doc from org. Run the query against this backend.
| |
| swapBackend | back to summary |
|---|---|
| private synchronized void swapBackend() | |
| updateEntry | back to summary |
|---|---|
| public synchronized void updateEntry(FieldChangedEvent event) Implements org.
| |