feat(E): Unified Search — 24 Tasks complete
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
- SPIKE-E: FTS+Vector+Permission benchmark on 10k records (all <30ms) - E-PROV: supports_fts/vector/rag/graph capability flags on all providers - E-FTS/VEC: All 11 providers refactored to BaseSearchProvider with permission filtering - E-PERM: Over-fetch strategy for vector+permission (15x faster than ANY() filter) - E-FUSE: rrf_fusion_multi() for N-way RRF over FTS+Vector+RAG+Graph - E-LLM: Query understanding cleaned up to use central llm_complete() - E-CHUNK: Document chunking module + document_chunks table with HNSW index - E-EMB: Chunk embedding ARQ jobs (index_file_chunks, reindex_chunks) - E-RAG: RAG retrieval via FileSearchProvider.search_rag() - E-GRAPH: GraphRAG BFS traversal via GraphRAGSearchProvider.search_graph() - E-IX-EVT: Auto-indexing via outbox events + delete/cleanup handlers - E-IX-RE: Batch reindex with progress tracking + reindex_all job - E-DATA-LIFE: Lifecycle module (remove/rebuild/restore/correct) + API endpoints - E-K-MEM: AgentMemorySearchProvider - E-P-AI: AIChatSearchProvider - E-P-WF: WorkflowSearchProvider - E-P-COMM: ConversationSearchProvider verified (already on BaseSearchProvider) - E-API: Filter params (date_from/to, tags, sort) + /facets endpoint - E-TOOL: unified_search AI tool registered in ToolRegistry - E-MCP: Search tool in MCP server with normal RBAC/tenant checks - E-UI-CMD: CommandPalette (Cmd+K) with debounced search + recent searches - E-UI-FAC: SearchFacets, SearchResultCard, SavedSearches components - E-TEST: 40 new tests in test_unified_search_phase_e.py (105 total green) - E-DOC: api-documentation.md, plugin-development-guide.md, test-strategy.md updated 105 tests passing, TypeScript clean.
This commit is contained in:
@@ -24,16 +24,16 @@ export * from './automation';
|
||||
|
||||
// ── Search hook (uses dynamic import, kept inline) ──
|
||||
|
||||
import type { SearchResult } from './search';
|
||||
export type { SearchResult };
|
||||
import type { SearchFilters, SearchResult } from './search';
|
||||
export type { SearchResult, SearchFilters };
|
||||
|
||||
export function useGlobalSearch(query: string, entityTypes?: string[]) {
|
||||
export function useGlobalSearch(query: string, filters: SearchFilters = {}) {
|
||||
return useQuery({
|
||||
queryKey: ['globalSearch', query, entityTypes],
|
||||
queryKey: ['globalSearch', query, filters],
|
||||
queryFn: async (): Promise<SearchResult[]> => {
|
||||
if (!query.trim()) return [];
|
||||
const { search } = await import('@/api/search');
|
||||
const response = await search(query, entityTypes, 20);
|
||||
const response = await search(query, filters, 20);
|
||||
return response.results || [];
|
||||
},
|
||||
enabled: query.trim().length > 0,
|
||||
|
||||
@@ -10,13 +10,32 @@ export interface SearchResult {
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface SearchFacet {
|
||||
value: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface SearchFilters {
|
||||
entityTypes?: string[];
|
||||
tags?: string[];
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
sort?: 'relevance' | 'date' | 'name';
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
results: SearchResult[];
|
||||
facets?: Record<string, Array<{ value: string; count: number }>>;
|
||||
facets?: Record<string, SearchFacet[]>;
|
||||
summary?: string;
|
||||
suggestions?: string[];
|
||||
}
|
||||
|
||||
export interface FacetsResponse {
|
||||
entity_types: string[];
|
||||
tags: string[];
|
||||
date_ranges: Record<string, { min: string | null; max: string | null }>;
|
||||
}
|
||||
|
||||
// Map backend entity_type to frontend route URL
|
||||
const ENTITY_URL_MAP: Record<string, (id: string, data?: Record<string, unknown>) => string> = {
|
||||
contact: (id) => `/contacts/${id}`,
|
||||
@@ -46,10 +65,14 @@ function mapBackendResult(r: Record<string, unknown>): SearchResult {
|
||||
};
|
||||
}
|
||||
|
||||
export async function search(query: string, entityTypes?: string[], limit = 20): Promise<SearchResponse> {
|
||||
export async function search(query: string, filters: SearchFilters = {}, limit = 20): Promise<SearchResponse> {
|
||||
const r = await apiClient.post('/search', {
|
||||
query,
|
||||
entity_types: entityTypes,
|
||||
entity_types: filters.entityTypes,
|
||||
tags: filters.tags,
|
||||
date_from: filters.dateFrom,
|
||||
date_to: filters.dateTo,
|
||||
sort: filters.sort || 'relevance',
|
||||
limit,
|
||||
});
|
||||
const data = r.data;
|
||||
@@ -63,6 +86,11 @@ export async function search(query: string, entityTypes?: string[], limit = 20):
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchFacets(): Promise<FacetsResponse> {
|
||||
const r = await apiClient.get('/search/facets');
|
||||
return r.data as FacetsResponse;
|
||||
}
|
||||
|
||||
export async function searchSuggest(q: string): Promise<string[]> {
|
||||
const r = await apiClient.get('/search/suggest', { params: { q } });
|
||||
return r.data.suggestions || [];
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { FacetsResponse } from './search';
|
||||
|
||||
export function useSearchFacets() {
|
||||
return useQuery({
|
||||
queryKey: ['searchFacets'],
|
||||
queryFn: async (): Promise<FacetsResponse> => {
|
||||
const { fetchFacets } = await import('@/api/search');
|
||||
return fetchFacets();
|
||||
},
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user