Documentation
¶
Index ¶
- type Option
- type Postgres
- func (p *Postgres) Create() error
- func (p *Postgres) Exists() bool
- func (p *Postgres) GetType() string
- func (p *Postgres) Retrieve(ctx context.Context, query string, opts ...retriever.Option) ([]*schema.Document, error)
- func (p *Postgres) Search(ctx context.Context, queryVector []float32, limit int, ...) ([]*schema.Document, error)
- func (p *Postgres) Store(ctx context.Context, docs []*schema.Document, opts ...indexer.Option) ([]string, error)
- type PostgresConfig
- type PostgresVectorDocument
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Postgres ¶
func NewPostgres ¶
func NewPostgres(config PostgresConfig) (*Postgres, error)
NewPostgres 使用现有GORM实例创建PostgreSQL向量数据库
func (*Postgres) Retrieve ¶
func (p *Postgres) Retrieve(ctx context.Context, query string, opts ...retriever.Option) ([]*schema.Document, error)
Retrieve 实现retriever.Retriever接口
type PostgresConfig ¶
type PostgresConfig struct {
Client *gorm.DB
CollectionName string // 集合名称
VectorDimension int // 向量维度
Embedding embedding.Embedder
}
PostgresConfig PostgreSQL配置
type PostgresVectorDocument ¶
type PostgresVectorDocument struct {
ID string `gorm:"column:id;primaryKey" json:"id"`
Content string `gorm:"column:content;type:text" json:"content"`
Vector string `gorm:"column:vector;type:vector" json:"vector"` // pgvector类型
Metadata string `gorm:"column:metadata;type:text" json:"metadata"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
}
PostgresVectorDocument PostgreSQL向量文档模型
Click to show internal directories.
Click to hide internal directories.