Navigation
API > API/Plugins > API/Plugins/SemanticSearch
Singleton that owns all search indices (vector + BM25) and fuses results using Reciprocal Rank Fusion (RRF).
All mutations, searches, and index queries are serialized through an internal command queue with a dedicated consumer thread. Public methods enqueue work (microsecond lock) and return immediately; async operations deliver results via game-thread callbacks. GetCachedIndexStats() provides a lock-free snapshot of index metrics that is safe to call from any thread.
| Name | FHybridSearchIndex |
| Type | class |
| Header File | /Engine/Plugins/Experimental/SemanticSearch/Source/SemanticSearch/Public/HybridSearchIndex.h |
| Include Path | #include "HybridSearchIndex.h" |
Syntax
class FHybridSearchIndex
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FHybridSearchIndex() |
HybridSearchIndex.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FHybridSearchIndex() |
HybridSearchIndex.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bInitialized | std::atomic< bool > | HybridSearchIndex.h | ||
| BM25Index | TUniquePtr< FBM25Index > | HybridSearchIndex.h | ||
| FailedAssets | TSet< int64 > | Retryable failures. In-session only; cleared by the "Retry failed" button and on force-rebuild. | HybridSearchIndex.h | |
| IndexId | std::atomic< uint32 > | HybridSearchIndex.h | ||
| OnIndexChangedDelegate | FOnIndexChanged | HybridSearchIndex.h | ||
| PreProcessorFailedAssets | TSet< int64 > | Permanent failures. | HybridSearchIndex.h | |
| QueueData | TUniquePtr< FCommandQueueData > | HybridSearchIndex.h | ||
| VectorIndex | TSharedPtr< IVectorIndex > | HybridSearchIndex.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Add
(
FAssetData Asset, |
Add a single asset to both indices. Lazily creates vector index on first call. | HybridSearchIndex.h | |
void AddQuantized
(
FAssetData Asset, |
Add a single asset using pre-quantized codes (no float embedding). | HybridSearchIndex.h | |
void ClearBM25() |
Clear the BM25 text index. | HybridSearchIndex.h | |
void ClearFailedState
(
int64 AssetId |
Remove an asset ID from both failed sets. Used by the retry button. | HybridSearchIndex.h | |
void ContainsAsync
(
TArray< int64 > IDs, |
Async contains check. Tests which IDs are present in the index on the consumer thread. | HybridSearchIndex.h | |
void DiscardPendingMutations() |
Discard all pending mutations (used during cancel). | HybridSearchIndex.h | |
void EnsureInitialized
(
int32 EmbeddingDimension |
Ensure the index is initialized with a valid (possibly empty) vector index. | HybridSearchIndex.h | |
void ExtractEmbeddingsAsync
(
TArray< int64 > CandidateIDs, |
Async extraction of all stored vectors for training. Runs on the consumer thread. | HybridSearchIndex.h | |
FIoHash GetCachedCodebookHash() |
Get the codebook hash from cached stats. Returns default FIoHash if not quantized/trained. | HybridSearchIndex.h | |
| Get a snapshot of index stats. | HybridSearchIndex.h | ||
uint32 GetIndexId() |
Get the current index ID (changes on index swap/invalidation). | HybridSearchIndex.h | |
void InvalidateIndexId() |
Invalidate the current IndexId so stale callbacks are dropped. | HybridSearchIndex.h | |
void IsFailedAsync
(
TArray< int64 > IDs, |
Async failed-set check. | HybridSearchIndex.h | |
bool IsHybridEnabled() |
Whether BM25 hybrid search is enabled (from settings). | HybridSearchIndex.h | |
void IsRetryableFailedAsync
(
TArray< int64 > IDs, |
Async retryable-failed check. | HybridSearchIndex.h | |
bool LoadFromFile
(
const FString& FilePath, |
Load a previously saved index from a file. | HybridSearchIndex.h | |
void LoadPreProcessorFailedFromFile
(
const FString& FilePath |
Load the pre-processor-failed ID list from a sidecar file. | HybridSearchIndex.h | |
void MarkFailed
(
int64 AssetId, |
Record that an asset failed to index. | HybridSearchIndex.h | |
FOnIndexChanged & OnIndexChanged () |
Delegate broadcast when the index changes (e.g. after switching type or retraining). | HybridSearchIndex.h | |
void PurgePreProcessorFailedNotIn
(
TSet< int64 > ValidIDs |
Purge pre-processor-failed IDs that are not in the given set of currently-valid IDs. | HybridSearchIndex.h | |
void QuantizeAsync
(
TArray< float > Embedding, |
Async quantize. | HybridSearchIndex.h | |
void Remove
(
FAssetData Asset |
Remove a single asset from both indices. | HybridSearchIndex.h | |
void RemoveById
(
int64 AssetId |
Remove by pre-computed ID. | HybridSearchIndex.h | |
void RemoveByPath
(
FString AssetPath |
Remove by path string (for when the asset has already been deleted). | HybridSearchIndex.h | |
void ResetBM25AndFailedState () |
Reset BM25 and failed sets (enqueued to consumer thread). | HybridSearchIndex.h | |
void Save
(
FString FilePath, |
Save the full index (vector + BM25 + package hashes) to a file, and the pre-processor-failed ID list to a sidecar file alongside it. | HybridSearchIndex.h | |
void SearchAsync
(
FString QueryText, |
Async search. Fuses vector + BM25 results via RRF. | HybridSearchIndex.h | |
void SetVectorIndex
(
TSharedPtr< IVectorIndex > NewIndex |
Replace the vector index. Used during index type switching. | HybridSearchIndex.h | |
void StartCommandQueue() |
Start the background consumer thread. | HybridSearchIndex.h | |
void StopCommandQueue() |
Stop the background consumer thread and join. | HybridSearchIndex.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static FHybridSearchIndex & Get() |
HybridSearchIndex.h | ||
static FString GetCodebookPath
(
ESemanticSearchIndexType Type |
Get the path to the shared codebook file for the given index type (in plugin Resources/). | HybridSearchIndex.h | |
static void WriteBytesToFile
(
const FString& FilePath, |
HybridSearchIndex.h |