# Highlighting changes from 1.7 to 2.3

**URL:** <https://discuss.elastic.co/t/highlighting-changes-from-1-7-to-2-3/49661>\
**Category:** Elasticsearch\
**Created:** [May 10, 2016, 1:46pm UTC](https://discuss.elastic.co/t/highlighting-changes-from-1-7-to-2-3/49661 "2016-05-10T13:46:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philv](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@philv](https://discuss.elastic.co/u/philv)\
**Post date:** [May 10, 2016, 1:46pm UTC](https://discuss.elastic.co/t/highlighting-changes-from-1-7-to-2-3/49661/1 "2016-05-10T13:46:22Z")

</div>

When running a span\_near query in ES 1.7, the highlighting took account of in\_order and slop when it highlighted terms, however in ES 2.3 this no longer seems to be the case. My case extends this one:

> <https://stackoverflow.com/questions/34362043/how-do-you-highlight-span-near-queries-in-elasticsearch>

Here's how you'd repeat it.

```
curl -XPUT 'http://localhost:9200/twitter/' -d '{
    "mappings": {
        "tweet": {
            "properties": {
                "message": {
                    "type": "string", 
                    "store": true
                }
            }
        }
    }
}'

curl -XPUT 'localhost:9200/twitter/tweet/1?refresh=true' -d '{
    "message" : ["short leg twice syndrome","short syndrome"]
}'

```

Then run this span\_near query:

```
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty' -d '{
    "query" : {
        "span_near" : {
            "clauses" : [
                {"span_term": {"message": "short"}}, 
                {"span_term": {"message": "syndrome"}}
            ], 
            "slop": 0, 
            "in_order": true
        }
    }, 
    "highlight": {"fields": {"message": {"type": "plain"} } }
}'

```

in ES 1.7.1 you get:

```
{
  "took" : 56,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.11072598,
    "hits" : [ {
      "_index" : "twitter",
      "_type" : "tweet",
      "_id" : "1",
      "_score" : 0.11072598,
      "_source":{
    "message" : ["short leg twice syndrome","other words short syndrome"]
},
      "highlight" : {
        "message" : [**"other words <em>short</em> <em>syndrome</em>"**]
      }
    } ]
  }
}

```

in ES 2.3.2:

```
{
  "took" : 56,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.19178301,
    "hits" : [ {
      "_index" : "twitter",
      "_type" : "tweet",
      "_id" : "1",
      "_score" : 0.19178301,
      "_source" : {
        "message" : ["short leg twice syndrome", "other words short syndrome"]
      },
      "highlight" : {
        "message" : [**"<em>short</em> leg twice <em>syndrome</em>", "other words <em>short</em> <em>syndrome</em>"**]
      }
    } ]
  }
}

```

In 2.3.2 , 'short' and 'syndrome' in "_short leg twice syndrome_" get highlighted, even though they don't fulfill the terms of the slop/inorder parts of the span\_near query.

Is this an intentional change ? If it is, then is there a way to work around it to get back to the 1.7.1-stye highlighting where slop/inorder get accounted for ?

Many thanks,  
Phil

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 10, 2016, 3:05pm UTC](https://discuss.elastic.co/t/highlighting-changes-from-1-7-to-2-3/49661/2 "2016-05-10T15:05:13Z")

</div>

Hmm, this looks like a bug to me. I've opened a ticket for you so we can track the issue: [https://github.com/elastic/elasticsearch/issues/18246](https://github.com/elastic/elasticsearch/issues/18246)

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:** [July 5, 2017, 10:52pm UTC](https://discuss.elastic.co/t/highlighting-changes-from-1-7-to-2-3/49661/3 "2017-07-05T22:52:45Z")

</div>


