vec model and fix log

This commit is contained in:
Erik Winter 2023-07-06 13:58:12 +02:00
parent f4c856df68
commit 937eb32e93
3 changed files with 13 additions and 4 deletions

View File

@ -26,3 +26,8 @@ type Video struct {
Summary string
}
type VideoVec struct {
ID uuid.UUID
Summary string
}

View File

@ -22,7 +22,7 @@ import (
func main() {
ctx := context.Background()
logger := slog.New(slog.NewTextHandler(os.Stderr))
logger := slog.New(slog.NewTextHandler(os.Stdout))
postgres, err := storage.NewPostgres(storage.PostgresInfo{
Host: getParam("POSTGRES_HOST", "localhost"),

View File

@ -64,7 +64,11 @@ func (w *Weaviate) ResetSchema() error {
}
func (w *Weaviate) Save(ctx context.Context, video *model.Video) error {
vID := video.ID.String()
vec := model.VideoVec{
ID: video.ID,
Summary: video.Summary,
}
vID := vec.ID.String()
// check it already exists
exists, err := w.client.Data().
Checker().
@ -80,7 +84,7 @@ func (w *Weaviate) Save(ctx context.Context, video *model.Video) error {
Updater().
WithID(vID).
WithClassName(className).
WithProperties(video).
WithProperties(vec).
Do(ctx)
}
@ -88,7 +92,7 @@ func (w *Weaviate) Save(ctx context.Context, video *model.Video) error {
Creator().
WithClassName(className).
WithID(vID).
WithProperties(video).
WithProperties(vec).
Do(ctx)
return err