# Exact match on fields of type "text" (beginning and end "anchored")

**URL:** https://discuss.elastic.co/t/exact-match-on-fields-of-type-text-beginning-and-end-anchored/238435
**Category:** Elasticsearch
**Created:** [June 24, 2020, 10:30am UTC](https://discuss.elastic.co/t/exact-match-on-fields-of-type-text-beginning-and-end-anchored/238435 "2020-06-24T10:30:18Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jessepeixoto](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jessepeixoto](https://discuss.elastic.co/u/jessepeixoto)
#### Post date: [June 28, 2020, 9:03pm UTC](https://discuss.elastic.co/t/exact-match-on-fields-of-type-text-beginning-and-end-anchored/238435/2 "2020-06-28T21:03:44Z")

</div>

Hi @ypid-geberit,

I think a solution for your use case would be by using a normalizer that is a kind of analyzer for keyword, and it produces a single token at the end. [https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html)

If you really don't want to use keyword for your use case, in the book [Relevant Search](https://www.manning.com/books/relevant-search) by Doug Turnbull and John Berryman, they proposes an interesting solution for that question that are the sentinel tokens. You add tokens in the boundaries of the text even in the ingest as in the search part.

```
PUT ypid-exact-match-of-text-test
{
  "mappings": {
    "properties": {
      "text": {
        "type": "text"
      }
    }
  }
}

POST ypid-exact-match-of-text-test/_doc
{
  "text": "SENTINEL_BEGIN You Know, for Search SENTINEL_END"
}

POST ypid-exact-match-of-text-test/_doc
{
  "text": "SENTINEL_BEGIN Elastic Stack SENTINEL_END"
}

POST ypid-exact-match-of-text-test/_doc
{
  "text": "SENTINEL_BEGIN You Know, for Search (Elastic Stack) SENTINEL_END"
}

```

The search part would also have the sentinel tokens. In order to match exactly the phase you would have to use [match phase query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html) along with [boolean queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html), like the example below.

```
GET ypid-exact-match-of-text-test/_search?filter_path=hits.hits._source.text
{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "text": "SENTINEL_BEGIN You Know, for Search SENTINEL_END"
          }
        },
        {
          "match_phrase": {
            "text": "SENTINEL_BEGIN Elastic Stack SENTINEL_END"
          }
        }
      ]
    }
  }
}
```

---

_[View the full topic](https://discuss.elastic.co/t/exact-match-on-fields-of-type-text-beginning-and-end-anchored/238435)._
