使用继承的结构数组属性对搜索进行排名

问题描述

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

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_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

如果从complex_base.name函数中取出nativeRank,它将正确编译。另外,如果您尝试在提供以下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

如果这是预期的行为,那么除了复制/粘贴代码外,还有其他解决方法 将complex_base字段放入每个需要继承的文档中?谢谢您的协助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)