# Search\_as\_you\_type and highlight

**URL:** <https://discuss.elastic.co/t/search-as-you-type-and-highlight/253010>\
**Category:** Elasticsearch\
**Created:** [October 22, 2020, 1:42pm UTC](https://discuss.elastic.co/t/search-as-you-type-and-highlight/253010 "2020-10-22T13:42:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [November 3, 2020, 1:40am UTC](https://discuss.elastic.co/t/search-as-you-type-and-highlight/253010/2 "2020-11-03T01:40:12Z")

</div>

```auto
PUT test
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "search_as_you_type"
      }
    }
  }
}

PUT test/_doc/1
{
  "my_field": "quick brown fox jump lazy dog"
}

GET test/_search
{
  "query": {
    "multi_match": {
      "query": "brown fox ",
      "type": "bool_prefix",
      "fields": [
        "my_field",
        "my_field._2gram",
        "my_field._3gram"
      ]
    }
  },
  "highlight": {
    "fields": {
      "my_field": {
        "type" : "unified"
      }
    }
  }
}

```

That leads to the result:

```auto
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 0.8630463,
        "_source" : {
          "my_field" : "quick brown fox jump lazy dog"
        },
        "highlight" : {
          "my_field" : [
            "quick <em>brown</em> <em>fox</em> jump lazy dog"
          ]
        }
      }
    ]

```

It will only highlight matching tokens — if you leave out the space after fox, it won't mark that. Are you expecting partial highlighting instead? Not sure this would make sense for an autocomplete / search as you type field.

---

_[View the full topic](https://discuss.elastic.co/t/search-as-you-type-and-highlight/253010)._
