# Highlight property not appearing in hits

**URL:** <https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345>\
**Category:** Elasticsearch\
**Created:** [February 22, 2016, 12:13am UTC](https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345 "2016-02-22T00:13:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![radar](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@radar](https://discuss.elastic.co/u/radar)\
**Post date:** [February 22, 2016, 12:13am UTC](https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345/1 "2016-02-22T00:13:14Z")

</div>

I'm trying to get highlights returned in results when I do a query with some highlights. I'm using Elasticsearch 2.2. Here's the query + results that I've tried so far:

```auto
curl -X GET http://localhost:9200/teg_test_news/_search -d '{
  "query": {
    "match": {
      "_all": {
        "query": "Lorem",
        "operator":"and"
      }
    }
  },
  "highlight": {
    "pre_tags": ["<span class=\"match\">"],
    "post_tags": ["</span>"],
    "fields": {
      "title": {},
      "body": {}
    }
  },
  "_source": true
}'

```

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.10848885,
    "hits": [
      {
        "_index": "teg_test_news",
        "_type": "news",
        "_id": "1",
        "_score": 0.10848885,
        "_source": {
          "id": "1",
          "title": "Bob's Bikes to open new store in Lorem",
          "body": "\nLorem Ipsum\n\n"
        }
      }
    ]
  }
}

```

As you can see, the hit returned does not have any highlights.

However, when I use Elasticsearch 1.7 I _am_ getting highlights:

```auto
{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.10848885,
    "hits": [
      {
        "_index": "teg_test_news",
        "_type": "news",
        "_id": "1",
        "_score": 0.10848885,
        "_source": {
          "id": "1",
          "title": "Bob's Bikes to open new store in Lorem",
          "body": "\nLorem Ipsum\n\n"
        },
        "highlight": {
          "title": [
            "Bob's Bikes to open new store in <span class=\"match\">Lorem</span>"
          ],
          "body": [
            "\n<span class=\"match\">Lorem</span> Ipsum\n\n"
          ]
        }
      }
    ]
  }
}

```

What do I need to change here so that I get highlights returned in hits in Elasticsearch 2.2?

---

<div class="post-metadata">

**Author:** ![radar](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@radar](https://discuss.elastic.co/u/radar)\
**Post date:** [February 22, 2016, 4:53am UTC](https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345/2 "2016-02-22T04:53:42Z")

</div>

I had to change the query to query on the fields explicitly:

```ruby
 queries[:query] = {
  bool: {
    should: [
      {
        match: {
          body: { query: query, operator: 'and' }
        }
      },
      {
        match: {
          title: { query: query, operator: 'and' }
        }
      }
    ]
  }

```

I don't know if this is the right way to do it, but it makes the test pass and so I am happy.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [February 22, 2016, 5:08am UTC](https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345/3 "2016-02-22T05:08:57Z")

</div>

> [@radar](#):
>
> I had to change the query to query on the fields explicitly:

You can also set [require\_field\_match](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#field-match) to false. I believe the default changed from false to true in 2.0 but I can't find the reference.

BTW you can also use `multi_match` if you'd like to mention all the fields.

---

<div class="post-metadata">

**Author:** ![radar](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@radar](https://discuss.elastic.co/u/radar)\
**Post date:** [February 23, 2016, 2:54am UTC](https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345/4 "2016-02-23T02:54:05Z")

</div>

> [@nik9000](#):
>
> You can also set require\_field\_match to false. I believe the default changed from false to true in 2.0 but I can't find the reference.

Thanks Nik, this is spot on. That's allowed me to keep the query simple while still being able to highlight both of those fields.

---

<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:** [July 5, 2017, 11:14pm UTC](https://discuss.elastic.co/t/highlight-property-not-appearing-in-hits/42345/5 "2017-07-05T23:14:19Z")

</div>


