Your `multi_match` simply needs to be in its own array element
'query' => [
'bool' => [
'must' => [
[
'multi_match' => [ // ^1 means that title field has a higher priority in search tree
'fields' => ['title^1'],
'type' => 'phrase_prefix',
'query' => $query,
]
],
[
'term' => ['status' => ProductStatus::ACTIVE]
],
],
],
],
Also it would be more efficient to do it this way by moving the constraint on `status` in `bool/filter`:
'query' => [
'bool' => [
'must' => [
[
'multi_match' => [ // ^1 means that title field has a higher priority in search tree
'fields' => ['title^1'],
'type' => 'phrase_prefix',
'query' => $query,
]
]
],
'filter' => [
[
'term' => ['status' => ProductStatus::ACTIVE]
],
],
],
],
You're almost there, in the first `should` clause you need to remove the first `query`, i.e. `query_string` should be at top level
$query = [
'bool' => [
'should' => [
['query_string' => [ //parent root <-- modify this clause
'fields' => ['manufacturer_code', 'ean'],
'query' => $search,
],
],
['nested' => [ //nested parent.lang
'path' => 'lang',
'query' => [
'query_string' => [
'fields' => 'lang.name',
'query' => $search ,
],
],
]],
['nested' => [ //nested parent.product_base.lang
'path' => 'product_base.lang',
'query' => [
'query_string' => [
'fields' => 'product_base.lang.meta_keywords',
'query' => $search ,
],
],
]],
],
'minimum_should_match' => 1,
],
];