Add comprehensive Bible search feature
- Implement backend search engine with indexing and relevance scoring - Add search API endpoints (/api/search and /api/search/suggestions) - Create SearchComponent with modal and page views - Add search button to header navigation - Support real-time search with debouncing - Include context verses and search term highlighting - Add book filtering and mobile-responsive design - Integrate with existing routing and navigation system
This commit is contained in:
@@ -32,3 +32,56 @@ export const checkHealth = async (): Promise<{ status: string; message: string }
|
||||
const response = await api.get('/health');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// Search interfaces
|
||||
export interface SearchResult {
|
||||
book: string;
|
||||
chapter: number;
|
||||
verse: number;
|
||||
text: string;
|
||||
fullText: string;
|
||||
context: Array<{
|
||||
book: string;
|
||||
chapter: number;
|
||||
verse: number;
|
||||
text: string;
|
||||
}>;
|
||||
relevance: number;
|
||||
highlight: string;
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
query: string;
|
||||
results: SearchResult[];
|
||||
total: number;
|
||||
hasMore: boolean;
|
||||
}
|
||||
|
||||
export interface SearchOptions {
|
||||
book?: string;
|
||||
limit?: number;
|
||||
context?: boolean;
|
||||
}
|
||||
|
||||
// Search API functions
|
||||
export const searchBible = async (query: string, options: SearchOptions = {}): Promise<SearchResponse> => {
|
||||
const params = new URLSearchParams({
|
||||
q: query,
|
||||
...(options.book && { book: options.book }),
|
||||
...(options.limit && { limit: options.limit.toString() }),
|
||||
...(options.context !== undefined && { context: options.context.toString() })
|
||||
});
|
||||
|
||||
const response = await api.get(`/api/search?${params}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getSearchSuggestions = async (query: string, limit: number = 10): Promise<string[]> => {
|
||||
const params = new URLSearchParams({
|
||||
q: query,
|
||||
limit: limit.toString()
|
||||
});
|
||||
|
||||
const response = await api.get(`/api/search/suggestions?${params}`);
|
||||
return response.data.suggestions;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user