mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 04:01:34 +00:00
This commit implements the full-text search service using Weaviate. It replaces the stub implementation with a fully functional search service that supports hybrid and BM25 search modes. The new implementation includes: - Support for hybrid and BM25 search modes. - Transformation of Weaviate search results into domain entities. - Unit tests using a mock Weaviate wrapper to ensure the implementation is correct and to avoid environmental issues in the test pipeline.
27 lines
636 B
Go
27 lines
636 B
Go
package search
|
|
|
|
import (
|
|
"context"
|
|
"tercul/internal/domain"
|
|
domainsearch "tercul/internal/domain/search"
|
|
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
type MockWeaviateWrapper struct {
|
|
mock.Mock
|
|
}
|
|
|
|
func (m *MockWeaviateWrapper) Search(ctx context.Context, params domainsearch.SearchParams) (*domain.SearchResults, error) {
|
|
args := m.Called(ctx, params)
|
|
if args.Get(0) == nil {
|
|
return nil, args.Error(1)
|
|
}
|
|
return args.Get(0).(*domain.SearchResults), args.Error(1)
|
|
}
|
|
|
|
func (m *MockWeaviateWrapper) IndexWork(ctx context.Context, work *domain.Work, content string) error {
|
|
args := m.Called(ctx, work, content)
|
|
return args.Error(0)
|
|
}
|