# Highlight does not work properly with ScriptScore, version 7.8

**URL:** <https://discuss.elastic.co/t/highlight-does-not-work-properly-with-scriptscore-version-7-8/241584>\
**Category:** Elasticsearch\
**Created:** [July 17, 2020, 6:22am UTC](https://discuss.elastic.co/t/highlight-does-not-work-properly-with-scriptscore-version-7-8/241584 "2020-07-17T06:22:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurjit\_buck](https://avatars.discourse-cdn.com/v4/letter/g/4af34b/32.png) [@gurjit\_buck](https://discuss.elastic.co/u/gurjit_buck)\
**Post date:** [July 17, 2020, 6:22am UTC](https://discuss.elastic.co/t/highlight-does-not-work-properly-with-scriptscore-version-7-8/241584/1 "2020-07-17T06:22:06Z")

</div>

**Elasticsearch version** (`7.8`):

**OS version** (`Windows 10`):

**Along with ScriptScore function, Highlight function does not work properly. If we search two words only first word gets higlighted or last word doesn't display highlighted** :

Eg. Doc content- this is a boy  
On searching - this is  
Output content shows only 'this' as highlighted

```auto
       var searchResponse = await elasticClient.SearchAsync<Document>(body => body

           .Index(Settings.Index + "-*")
                 .Query(qx =>

                         qx.ScriptScore(fx => fx
                   .Query(qt =>

                    qt.Bool
                  (bb => bb.Must(q =>
                     q.MatchPhrasePrefix(m => m.Field(f => f.Content).Query(req.SearchText))) // q.Terms(c => c.Field(p => p.Tags).Terms(words))

                   ) 
    )
                    .Script(w => w.Source("String gmtString = params.searchdate;ZonedDateTime zdt = ZonedDateTime.parse(gmtString,DateTimeFormatter.RFC_1123_DATE_TIME);ZonedDateTime zdt2 =ZonedDateTime.of(doc['date'].value.year,doc['date'].value.monthOfYear,doc['date'].value.dayOfMonth,doc['date'].value.hourOfDay,doc['date'].value.minuteOfHour,doc['date'].value.secondOfMinute, 0, ZoneId.of('Z')); if (zdt2.toInstant().toEpochMilli()==zdt.toInstant().toEpochMilli()){return 100;}else{return _score;} ").Params(par))) 

           ).Highlight(h => h.Fields(
                 fs => fs
        .Field(p => p.Content)
           .NumberOfFragments(0),
     fs => fs
        .Field(p => p.Attachment.Content).NumberOfFragments(0).Type(HighlighterType.Unified)
        ).PreTags("<b>").PostTags("</b>")));
 

```

Please suggest any solution

---

<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:** [August 14, 2020, 6:22am UTC](https://discuss.elastic.co/t/highlight-does-not-work-properly-with-scriptscore-version-7-8/241584/2 "2020-08-14T06:22:11Z")

</div>

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