The searchable tables and fields are now standard QQQ records: quick_search_index (the registry; new source and ownerEdited columns) and the new quick_search_index_field (weight, role, analyzer, snippet and label flags). Indexing, search, the record-search provider and the diagnostics read the effective config from them through QuickSearchConfigStore (30 s cache, dropped by the tables' customizers), so changes need no redeploy. Code (@QuickSearchable, searchableTables) only seeds the records: QuickSearchConfigPrimer adds missing tables and fields at startup and queues their builds, updates rows nobody edited, never overwrites rows an admin edited (ownerEdited) and never re-adds what an admin removed (quick_search_config_tombstone). Basepull builds queued tables (PENDING_BUILD, BUILDING) and recreates a missing index; an empty index is rebuilt. Without the config tables the code config is used as before. The generic Create and Delete of quick_search_index are replaced by streamed-ETL processes with review steps: Add Search Index (eligible readable tables only, estimated record count, default fields, sensitive and hidden fields never indexed), Apply Search Index Changes (previews field changes, then rebuilds), Disable / Remove Search Index (delete or keep documents), Cancel Index Run (cooperative flag between batches; runs end CANCELLED with counts) and Pause / Resume Indexing (global pause in quick_search_settings; search keeps serving; changes are deferred and replayed). Field roles shape documents (TITLE label, SUBTITLE, DISPLAY values, KEYWORD and EXACT outside the snippet) and WORD, ENGLISH and EXACT analyzers get their own document objects and mapping templates. Config tables are audited at field level and permission-gated; the processes need quick_search_admin. Upgrade notes and DDL: docs/MIGRATION-1.1.md, "Data-driven configuration". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
3.4 KiB
Java
105 lines
3.4 KiB
Java
/*
|
|
* Copyright 2024 Kingsrook, LLC
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.kingsrook.qbits.quicksearch;
|
|
|
|
|
|
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
|
import com.kingsrook.qqq.backend.core.instances.QRuntimeServiceInterface;
|
|
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
|
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitMetaData;
|
|
|
|
|
|
/*******************************************************************************
|
|
** Lifecycle hook for hosts that start through QApplicationLauncher: prepares
|
|
** the OpenSearch index on start (per startupMode) and closes the transport on
|
|
** stop. Hosts without a launcher get the same start behaviour from produce()
|
|
** in FAIL_FAST mode and lazily on first use in DEGRADED mode.
|
|
*******************************************************************************/
|
|
public class QuickSearchRuntimeService implements QRuntimeServiceInterface
|
|
{
|
|
private static final QLogger LOG = QLogger.getLogger(QuickSearchRuntimeService.class);
|
|
|
|
private QuickSearchRuntime runtime;
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
**
|
|
*******************************************************************************/
|
|
@Override
|
|
public String getName()
|
|
{
|
|
return ("quickSearch");
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
**
|
|
*******************************************************************************/
|
|
@Override
|
|
public void start(QInstance qInstance) throws QException
|
|
{
|
|
runtime = findRuntime(qInstance);
|
|
if(runtime == null)
|
|
{
|
|
LOG.warn("Quick Search runtime service started, but no produced Quick Search QBit was found in the QInstance");
|
|
return;
|
|
}
|
|
runtime.setStartInstance(qInstance);
|
|
runtime.start();
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
**
|
|
*******************************************************************************/
|
|
@Override
|
|
public void stop()
|
|
{
|
|
if(runtime != null)
|
|
{
|
|
runtime.close();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Find the runtime on the instance's Quick Search QBit (not through
|
|
** QContext, which may not be set when the launcher starts services).
|
|
*******************************************************************************/
|
|
static QuickSearchRuntime findRuntime(QInstance qInstance)
|
|
{
|
|
if(qInstance == null || qInstance.getQBits() == null)
|
|
{
|
|
return (null);
|
|
}
|
|
for(QBitMetaData qBitMetaData : qInstance.getQBits().values())
|
|
{
|
|
if(qBitMetaData.getConfig() instanceof QuickSearchQBitConfig config && config.getRuntime() != null)
|
|
{
|
|
return (config.getRuntime());
|
|
}
|
|
}
|
|
return (null);
|
|
}
|
|
|
|
}
|