# Query\_string not match with Should Condions

**URL:** <https://discuss.elastic.co/t/query-string-not-match-with-should-condions/281038>\
**Category:** Elasticsearch\
**Created:** [August 11, 2021, 10:42am UTC](https://discuss.elastic.co/t/query-string-not-match-with-should-condions/281038 "2021-08-11T10:42:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![enrico.bellanti](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@enrico.bellanti](https://discuss.elastic.co/u/enrico.bellanti)\
**Post date:** [August 11, 2021, 10:42am UTC](https://discuss.elastic.co/t/query-string-not-match-with-should-condions/281038/1 "2021-08-11T10:42:05Z")

</div>

My intention is to find a word in all documents which have this condions:  
("type" =\> "Faq") OR ("type" =\> "NormativeDoc") OR ("type" =\> "Document" AND "profile\_id\_document" =\> X).

I tried this but it doesn't work:

```auto
$params = [
            'index' => global_index,
            'type' => 'documento_globale',
            'body' => [
                'query' => [
                    'bool' => [
                        'must' => [
                                'query_string' => [
                                    'query' => "{$keyword}"
                                ]
                        ],
                        "should" => [
                            [
                             "match" => [
                                [
                                    "profile_id_document" => 32,
                                    "type" => "Document"
                                ]
                             ]
                            ],
                            [
                             "match" => [
                                "type" => "Faq"
                             ]
                            ],
                            [
                             "match" => [
                                "type" => "NormativeDocument"
                             ]
                            ]
                        ],
                    ]
                ]
            ]
        ];

```

it doesn't seems so difficult to do in SQL, but it seems impossible in elasticsearch. Can Anyone help me?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [August 11, 2021, 11:00am UTC](https://discuss.elastic.co/t/query-string-not-match-with-should-condions/281038/2 "2021-08-11T11:00:43Z")

</div>

`should` clauses are just optional extras when paired with `must` clauses. They add to the score.

If you need true OR logic you need `bool` query with only a `should` section. Your query in pseudocode would be:

```
 bool
     should 
            type : faq
            type : normativeDoc
            bool
                   must
                        type : Document
                        profile_id_document : X
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 8, 2021, 11:01am UTC](https://discuss.elastic.co/t/query-string-not-match-with-should-condions/281038/3 "2021-09-08T11:01:20Z")

</div>

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