Boolean filter question

Hello,

I have a problem with filter in boolean query.

I want to apply a filter based on 3 fields with 1 minimum filter match :

$params = [
    'from' => 0,
    'size' => 25,
    'index' => 'document',
    'body' => [
        'query' => [
            'bool' => [
                'filter' => [
                    'bool' => [
                        'minimum_should_match' => 1,
                        'should' => [
                            'term' => [
                                'VISIBILITE' => 'T'
                            ],
                            'term' => [
                                'ECRITURE' => 'M'
                            ],
                            'term' => [
                                'LECTURE' => 'M'
                            ],
                        ]
                    ]
                ],
                'must' => [
                    [
                        'bool' => [
                            'should' => [ 
                                [
                                    'match' => [
                                        'OBJET' => $recherche,
                                    ]
                                ],
                                [
                                    'match' => [
                                        'TYPEDOCUMENT' => $recherche
                                    ]
                                ],
                                [
                                    'match' => [
                                        'NOMPERSONNE' => $recherche
                                    ]
                                ],
                                [
                                    'match' => [
                                        'PRENOMPERSONNE' => $recherche
                                    ]
                                ],
                                [
                                    'match' => [
                                        'NUMDOCUMENT' => [
                                            'query' => $recherche,
                                            'boost' => 2
                                        ]
                                    ]
                                ],
                                [
                                    'match' => [
                                        'MOTCLES' => $recherche
                                    ]
                                ],
                            ] 
                        ]
                    ],
                ],
            ],
        ],
    ],
];

I get no result with this query, however i see lots of relevant documents in index.

As this does not contain a fully reproducible example, I can only forward you to the Explain API, allowing you to figure out why a document does not match even though it should.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.