vec model and fix log
This commit is contained in:
parent
f4c856df68
commit
937eb32e93
|
@ -26,3 +26,8 @@ type Video struct {
|
|||
|
||||
Summary string
|
||||
}
|
||||
|
||||
type VideoVec struct {
|
||||
ID uuid.UUID
|
||||
Summary string
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue