Tencent/WeKnora · error

create opensearch repository: %w

Error message

create opensearch repository: %w

What it means

createOpenSearchEngine wraps openSearchRepo.NewRepository failure — typically the cluster probe (version/k-NN plugin check) failing or an invalid index config/store ID length. Failing at registration prevents first-query surprises.

Source

Thrown at internal/container/engine_factory.go:154

// registration rather than on first query.
func createOpenSearchEngine(
	ctx context.Context, store types.VectorStore, auditSink openSearchRepo.AuditSink,
) (interfaces.RetrieveEngineService, error) {
	client, err := openSearchRepo.NewOpenSearchClient(&store.ConnectionConfig)
	if err != nil {
		return nil, fmt.Errorf("create opensearch client: %w", err)
	}
	// Env stores share the cluster without a per-store index prefix; DB stores
	// fold their (>=16-char) ID into the index name. NewRepository enforces the
	// length rule, so map env-store IDs to "".
	storeID := store.ID
	if types.IsEnvStoreID(storeID) {
		storeID = ""
	}
	repo, err := openSearchRepo.NewRepository(ctx, client, storeID, &store.IndexConfig,
		openSearchRepo.WithAuditSink(auditSink))
	if err != nil {
		return nil, fmt.Errorf("create opensearch repository: %w", err)
	}
	return retriever.NewKVHybridRetrieveEngine(repo, types.OpenSearchRetrieverEngineType), nil
}

func createPostgresEngine(store types.VectorStore, db *gorm.DB) (interfaces.RetrieveEngineService, error) {
	if store.ConnectionConfig.UseDefaultConnection {
		repo := postgresRepo.NewPostgresRetrieveEngineRepository(db)
		return retriever.NewKVHybridRetrieveEngine(repo, types.PostgresRetrieverEngineType), nil
	}
	// Phase 1: only UseDefaultConnection is supported.
	// Custom connections require connection pool management and migration handling.
	return nil, fmt.Errorf("custom postgres connections not yet supported; use use_default_connection=true")
}

func createSQLiteEngine(_ types.VectorStore, db *gorm.DB) (interfaces.RetrieveEngineService, error) {
	repo := sqliteRetrieverRepo.NewSQLiteRetrieveEngineRepository(db)
	return retriever.NewKVHybridRetrieveEngine(repo, types.SQLiteRetrieverEngineType), nil
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the OpenSearch cluster is reachable and has the k-NN plugin
  2. Check the index config and store ID length rule
  3. Retry registration once the cluster is healthy
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/container/engine_factory.go:154 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/ce93cab04373159f. Report an issue: GitHub.