CopyPastor

Detecting plagiarism made easy.

Score: 0.8458271061353562; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2024-05-16
by Val

Original Post

Original - Posted on 2021-06-21
by Val



            
Present in both answers; Present only in the new answer; Present only in the old answer;

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, ], ];

        
Present in both answers; Present only in the new answer; Present only in the old answer;