# Cannot get highlight in using highlighting

**URL:** <https://discuss.elastic.co/t/cannot-get-highlight-in-using-highlighting/111721>\
**Category:** Elasticsearch\
**Created:** [December 14, 2017, 9:20am UTC](https://discuss.elastic.co/t/cannot-get-highlight-in-using-highlighting/111721 "2017-12-14T09:20:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![takleung](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@takleung](https://discuss.elastic.co/u/takleung)\
**Post date:** [December 14, 2017, 9:20am UTC](https://discuss.elastic.co/t/cannot-get-highlight-in-using-highlighting/111721/1 "2017-12-14T09:20:57Z")

</div>

Hi, when using "highlight" query. It seems nothing be highlight on return result. As the following, i want to highlight "text" in the content.

PUT [http://192.168.196.248:9200/\_ingest/pipeline/attachment](http://192.168.196.248:9200/_ingest/pipeline/attachment)  
{  
"description" : "Extract attachment information",  
"processors" : [  
{  
"attachment" : {  
"field" : "data"  
}  
}  
]  
}

PUT [http://192.168.196.248:9200/my\_index/my\_type/2?pipeline=attachment](http://192.168.196.248:9200/my_index/my_type/2?pipeline=attachment)  
{  
"filename" : "ipsum2.txt",  
"data" : "dGhpcyBpcwpqdXN0IHNvbWUgdGV4dAo="  
}

POST [http://192.168.196.248:9200/my\_index/my\_type/\_search](http://192.168.196.248:9200/my_index/my_type/_search)  
{  
"query" : {  
"match": { "attachment.content": "text" }  
},  
"highlight" : {  
"require\_field\_match": false,  
"fields": {  
"\_all" : { "pre\_tags" : ["_"], "post\_tags" : ["_"] }  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [December 22, 2017, 11:40am UTC](https://discuss.elastic.co/t/cannot-get-highlight-in-using-highlighting/111721/2 "2017-12-22T11:40:18Z")

</div>

Hi @takleung,

You were almost there. The issue here is that \_all field [need to be prepared for highlighting](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html#highlighting-all-field).

Furthermore \_all field is deprecated in 6.X so maybe its better to use "attachment.content" and it will work as your are expecting:

```
PUT /_ingest/pipeline/attachment
{
  "description": "Extract attachment information",
  "processors": [
    {
      "attachment": {
        "field": "data"
      }
    }
  ]
}

PUT /my_index/my_type/2?pipeline=attachment
{
  "filename": "ipsum2.txt",
  "data": "dGhpcyBpcwpqdXN0IHNvbWUgdGV4dAo="
}

POST /my_index/my_type/_search
{
  "query": {
    "match": {
      "attachment.content": "text"
    }
  },
  "highlight": {
    "require_field_match": false,
    "fields": {
      "attachment.content": {}
    }
  }
}

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.2876821,
    "hits": [
      {
        "_index": "my_index",
        "_type": "my_type",
        "_id": "2",
        "_score": 0.2876821,
        "_source": {
          "filename": "ipsum2.txt",
          "data": "dGhpcyBpcwpqdXN0IHNvbWUgdGV4dAo=",
          "attachment": {
            "content_type": "text/plain; charset=ISO-8859-1",
            "language": "en",
            "content": "this is\njust some text",
            "content_length": 24
          }
        },
        "highlight": {
          "attachment.content": [
            "this is\njust some <em>text</em>"
          ]
        }
      }
    ]
  }
}

```

Cheers,  
LG

---

<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:** [January 19, 2018, 11:40am UTC](https://discuss.elastic.co/t/cannot-get-highlight-in-using-highlighting/111721/3 "2018-01-19T11:40:24Z")

</div>

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