I am currently using document inheritance to avoid having to include specific fields in every document type that I make. It works for most scenarios, but when an array of structs is inherited, using that field in ranking and searching seems to break things. For example, take the following application.
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)
}
}
}
If you try to prepare this application, you will get the error
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
If you take out the complex_base.name
from the nativeRank
function, it will compile properly. Additionally if you try to search using the various fields after feeding the following json:
{
"put": "id:content:sub::0",
"fields": {
"simple_base": "simple",
"simple_sub": "simple",
"complex_base": [
{
"name": "complex"
}
],
"complex_sub": [
{
"name": "complex"
}
]
}
}
Then the following are the results:
/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
If this is the intended behavior then is there a workaround for this other than copy/pasting the
complex_base
field into every document that needs to inherit it? Thank you for your assistance.