在搜索排名中使用继承的结构数组属性

Using inherited struct array attributes in ranking an searching

我目前正在使用文档继承来避免在我创建的每个文档类型中都包含特定字段。它适用于大多数情况,但是当继承了一组结构时,在排名和搜索中使用该字段似乎会破坏事情。例如,采用以下应用程序。

schema base {
    document base {
        field simple_base type string {
            indexing: summary | index
        }

        struct base_struct {
            field name type string {}
        }

        field complex_base type array<base_struct> {
            indexing: summary
            struct-field name { indexing: attribute }
        }
    }
}
schema sub {
    document sub inherits base {
        field simple_sub type string {
            indexing: summary | index
        }

        struct sub_struct {
            field name type string {}
        }

        field complex_sub type array<sub_struct> {
            indexing: summary
            struct-field name { indexing: attribute }
        }
    }

    rank-profile default inherits default {
        first-phase {
            expression: nativeRank(simple_sub, complex_sub.name, simple_base, complex_base.name)
        }
    }
}

如果您尝试准备此应用程序,您将收到错误

WARNING: invalid rank feature 'nativeRank(simple_sub,complex_sub.name,simple_base,complex_base.name)': The parameter list used for setting up rank feature nativeRank is not valid: Param[3]: Field 'complex_base.name' was not found in the index environment

如果你从nativeRank函数中取出complex_base.name,它会正确编译。此外,如果您在输入以下 json:

后尝试使用各个字段进行搜索
{
  "put": "id:content:sub::0",
  "fields": {
    "simple_base": "simple",
    "simple_sub": "simple",
    "complex_base": [
      {
        "name": "complex"
      }
    ],
    "complex_sub": [
      {
        "name": "complex"
      }
    ]
  }
}

则结果如下:

/search/?query=simple_sub:simple -> 1 result
/search/?query=complex_sub.name:complex -> 1 result
/search/?query=simple_base:simple -> 1 result
/search/?query=complex_base.name:complex -> 0 results

如果这是预期的行为,那么除了 copy/pasting complex_base 字段变成每个文件都需要继承吗?感谢您的协助。

这与继承无关。 Vespa.ai 不支持对用户定义的结构字段进行排名。参见 https://github.com/vespa-engine/vespa/issues/11580