You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Weaviate:如何为嵌套属性生成专属向量?

解决Weaviate嵌套属性possibleValues.name的向量化问题

要让possibleValues下的name字段参与向量生成,你需要在NestedProperty配置中显式开启向量化开关——Weaviate默认仅对顶级属性执行向量化操作,嵌套属性需手动启用该配置。

修改后的Schema配置(Go代码)

entityClass := &models.Class{
    Class:       classEntity,
    Description: "A generic class to store various entities",
    Properties: []*models.Property{
        {
            Name:        propertyName,
            DataType:    []string{"text"},
            Description: "Name of the entity",
        },
        {
            Name:            propertyDescription,
            DataType:        []string{"text"},
            Description:     "Description of the entity",
            IndexSearchable: &indexSearchableFalse,
        },
        {
            Name:        propertyPossibleValues,
            DataType:    []string{"object[]"},
            Description: "Possible values for the entity",
            NestedProperties: []*models.NestedProperty{
                {
                    Name:              propertyName,
                    DataType:          []string{"text"},
                    Description:       "Name of the possible value",
                    VectorizeProperty: true, // 关键:启用该嵌套字段的向量化
                },
            },
        },
    },
    Vectorizer: "text2vec-transformers",
}

关键说明

  1. VectorizeProperty: true的作用:该参数会告知Weaviate向量器(此处为text2vec-transformers),需将该嵌套属性的内容纳入对象级向量的计算逻辑。
  2. 生效条件:修改Schema后,需重新导入数据(或更新现有对象),新生成的向量才会包含该嵌套字段的语义信息。
  3. 验证方式:
    • 重新插入对象后,调用/v1/objects?include=vector,vectorWeights接口,查看vectorWeights字段,会显示possibleValues.name的权重占比,确认其已参与向量生成。
    • 通过语义搜索(如nearText查询),测试是否能通过possibleValues.name的内容匹配到目标对象。

内容的提问来源于stack exchange,提问作者Bouramas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 21:13:31