Let's identify and outline all the issues we've encountered so far with the enhanced search functionality:
-
Parameter Name Mismatch: We discovered that the enhanced-search edge function was using parameter names that didn't match what the database function expected:
- Edge function was using:
limitandoffset - Database function expected:
max_resultsandresult_offset - We fixed this by updating the edge function parameter names
- Edge function was using:
-
Vector Type Issue: After fixing the parameter names, we encountered an error related to the vector type: "function array_length(public.vector, integer) does not exist"
- This suggests that the
pgvectorextension might not be properly installed or configured in the database - We attempted to check if the extension was installed but couldn't connect directly to the database
- This suggests that the
-
Database Connection Issues: We couldn't directly connect to the database to check extension status
- The hostname "db.ghjbtvyalvigvmuodaas.supabase.co" couldn't be resolved
-
Edge Function Error: When testing the enhanced-search edge function directly, we got an error from the database function
- First error was about parameter names
- Second error was about the vector type
-
API Route Error: The Next.js API route was reporting "Edge Function returned a non-2xx status code" when calling the enhanced-search edge function
It seems the primary issues are:
- Possible missing or misconfigured
pgvectorextension in the database - Mismatch between function parameter names in different parts of the codebase
- Possibly some networking/connection issues when accessing the database directly
These issues are preventing the enhanced search functionality from working properly. The vector type error is particularly concerning as it suggests a fundamental issue with how the vector data is being handled in the database.# Enhanced Search System Issues
Based on our testing and debugging, here are the key issues we've identified with the enhanced search functionality:
- Edge Function: Using
limitandoffsetparameters - Database Function: Expecting
max_resultsandresult_offsetparameters - We fixed this issue by updating the edge function parameter names, but other issues persist
- Error: "function array_length(public.vector, integer) does not exist"
- This indicates the
pgvectorextension may not be properly installed or configured in the database - Without this extension, vector operations essential for embedding-based search cannot function
- Unable to directly connect to the database to check the extension status
- The hostname "db.ghjbtvyalvigvmuodaas.supabase.co" couldn't be resolved
- This limits our ability to directly inspect and fix database-level issues
- Client application calls API route (
/api/enhanced-search) - API route calls the
query-embeddingsedge function to generate embeddings - API route then calls the
enhanced-searchedge function with these embeddings - The
enhanced-searchedge function calls thesearch_content_multi_strategydatabase function - This complex chain means multiple points of potential failure
- Error suggests the database function has a signature that doesn't match what's being called:
search_content_multi_strategy(analysis, debug, max_results, metadata_boost, query, query_embedding, result_offset, subreddits, use_fallback) - The function parameters may have changed but not all components were updated to reflect these changes
- The client-side
enhancedSearchfunction inlib/api/enhanced-search.tsis correctly generating embeddings - However, there are issues when those embeddings are passed to the enhanced-search edge function
- Possible environment discrepancies between development and production environments
- This might be causing different behavior between local development and the deployed Supabase instance
These issues collectively prevent the enhanced search functionality from working properly. The most critical appears to be the vector extension issue, which indicates a fundamental problem with how vector data is being processed in the database.