# Full Text Search Force Find All Tokens

**URL:** https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215
**Category:** Elasticsearch
**Created:** [October 10, 2022, 11:47am UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215 "2022-10-10T11:47:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Saeed\_Mozaffari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saeed_mozaffari/32/109489_2.png) [@Saeed\_Mozaffari](https://discuss.elastic.co/u/Saeed_Mozaffari)
#### Post date: [October 10, 2022, 11:47am UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215/1 "2022-10-10T11:47:49Z")

</div>

I try to implement full text search.  
I have a question related to this subject.  
I want to at search time, when i search a text, for example "Hello Saeed", return result only when all tokens of that text exist in a message.  
this means in "Hello Saeed" that contains "Hello" and "Saeed" tokens just must be return messages that exist both of the words not one of them.

Hello I am Saeed ---\> must be return  
Hello I am Mike ---\> must not be return (because at search time i searched "Hello Saeed" and 'Saeed' not exist in this sentence)

but for search "Hello" both of the previous sentences are approve.

finally my question is, how can i force text analyzer at search time to find all tokens are exist in search text?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [October 10, 2022, 12:18pm UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215/2 "2022-10-10T12:18:17Z")

</div>

Have a look at the [minimum\_should\_match parameter](https://www.elastic.co/guide/en/elasticsearch/reference/8.4/query-dsl-minimum-should-match.html).

---

<div class="post-metadata">

### Author: ![Saeed\_Mozaffari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saeed_mozaffari/32/109489_2.png) [@Saeed\_Mozaffari](https://discuss.elastic.co/u/Saeed_Mozaffari)
#### Post date: [October 10, 2022, 2:56pm UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215/3 "2022-10-10T14:56:57Z")

</div>

My query is

```auto
GET /message/_search
{
  "from": 0,
  "size": 10,
  "sort": {
    "@timestamp": "desc"
  },
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "roomId": [
              1,
              2
            ]
          }
        },
        {
          "match": {
            "message": "Hello Saeed"
          }
        },
        {
          "match": {
            "type": 0
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": 1000
            }
          }
        }
      ]
    }
  }
}

```

what i know, [minimum\_should\_match](https://www.elastic.co/guide/en/elasticsearch/reference/8.4/query-dsl-minimum-should-match.html) use for define minimum number should be match in list of match case.  
but in my question i want to force tokens existence that exist in a text message in ONE match item not multiple. so seems to [minimum\_should\_match](https://www.elastic.co/guide/en/elasticsearch/reference/8.4/query-dsl-minimum-should-match.html) is not useful here.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [October 10, 2022, 3:13pm UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215/4 "2022-10-10T15:13:54Z")

</div>

It is an option for your [match query](https://www.elastic.co/guide/en/elasticsearch/reference/8.4/query-dsl-match-query.html).

---

<div class="post-metadata">

### Author: ![Saeed\_Mozaffari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saeed_mozaffari/32/109489_2.png) [@Saeed\_Mozaffari](https://discuss.elastic.co/u/Saeed_Mozaffari)
#### Post date: [October 12, 2022, 6:24am UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215/5 "2022-10-12T06:24:22Z")

</div>

operator in match query is exactly my answer.

"operator = and" force match query to find all tokens that created previously by tokenizer in message analyzer

thanks

---

<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: [November 9, 2022, 6:24am UTC](https://discuss.elastic.co/t/full-text-search-force-find-all-tokens/316215/6 "2022-11-09T06:24:30Z")

</div>

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