@@ -127,10 +127,10 @@ func getTestEmbedding(client *openai.Client, model string) ([]float32, error) {
127127func (p * PostgresDB ) setupDatabase () error {
128128 ctx := context .Background ()
129129
130- // Enable extensions
130+ // Enable extensions - pg_textsearch is required for BM25 indexing
131131 _ , err := p .pool .Exec (ctx , "CREATE EXTENSION IF NOT EXISTS pg_textsearch" )
132132 if err != nil {
133- xlog . Warn ( "Failed to enable pg_textsearch extension" , "error " , err )
133+ return fmt . Errorf ( "failed to enable pg_textsearch extension (required for BM25 indexing): %w " , err )
134134 }
135135
136136 // Check if vectorscale extension is already installed
@@ -151,7 +151,7 @@ func (p *PostgresDB) setupDatabase() error {
151151 // Try pgvector as fallback
152152 _ , err = p .pool .Exec (ctx , "CREATE EXTENSION IF NOT EXISTS vector" )
153153 if err != nil {
154- xlog . Warn ( "Failed to enable vector extension" , "error " , err )
154+ return fmt . Errorf ( "failed to enable vector extension: %w " , err )
155155 }
156156 } else {
157157 vectorscaleInstalled = true
@@ -202,13 +202,14 @@ func (p *PostgresDB) setupDatabase() error {
202202 xlog .Warn ("Failed to create GIN index" , "error" , err )
203203 }
204204
205- // BM25 index
205+ // BM25 index - required for hybrid search
206+ indexName := fmt .Sprintf ("idx_%s_bm25" , p .tableName )
206207 _ , err = p .pool .Exec (ctx , fmt .Sprintf (`
207- CREATE INDEX IF NOT EXISTS idx_%s_bm25 ON %s
208+ CREATE INDEX IF NOT EXISTS %s ON %s
208209 USING bm25(full_text) WITH (text_config='english')
209- ` , p . tableName , p .tableName ))
210+ ` , indexName , p .tableName ))
210211 if err != nil {
211- xlog . Warn ( "Failed to create BM25 index" , "error " , err )
212+ return fmt . Errorf ( "failed to create BM25 index (required for hybrid search): %w " , err )
212213 }
213214
214215 // Vector index (try DiskANN first if vectorscale is available, fallback to HNSW)
0 commit comments