# Highlights are truncated?

**URL:** <https://discuss.elastic.co/t/highlights-are-truncated/4993>\
**Category:** Elasticsearch\
**Created:** [July 28, 2011, 11:20pm UTC](https://discuss.elastic.co/t/highlights-are-truncated/4993 "2011-07-28T23:20:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmurdoch](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jmurdoch](https://discuss.elastic.co/u/jmurdoch)\
**Post date:** [July 28, 2011, 11:20pm UTC](https://discuss.elastic.co/t/highlights-are-truncated/4993/1 "2011-07-28T23:20:33Z")

</div>

It appears that the results returned from a search query are  
truncating the contents of highlighted field. Am I doing something  
incorrectly here? Notice how the 'S' of Susana is truncated off in  
the highlight of the OWNERFULLN field.

Thanks in advance!

Query:

{  
"query" : {  
"query\_string" : {  
"query" : "Stump"  
}  
},  
"fields" : ["\*"],  
"highlight" : {  
"fields" : {  
"docSource.feature.attributes.OWNERFULLN" : {  
"fragment\_size" : 100  
}  
}  
}  
}

Result:

{  
"took" : 16,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 6,  
"max\_score" : 1.4052091,  
"hits" : [ {  
"\_index" : "blah",  
"_type" : "blahblah",  
"id" : "-1668604027_-2041742376\_\_261713",  
"\_score" : 1.4052091,  
"fields" : {  
"docSource.feature.attributes.OWNERFULLN" : "Susana Stump",  
"docLastCrawlDate" : "2011-07-25T13:52:04.000Z",  
"docSource.feature.attributes.OWNERFIRST" : "Susana",  
"docSource.feature.attributes.ZIPCODE" : "28216",  
"docSource.feature.attributes.SHAPE\_Length" :  
234.4772918513361,  
"docSource.feature.attributes.LANDVALUE" : 30000.0,  
"docSource.feature.attributes.STNAMEFULL" : "10003 Lomax Ridge  
DR",  
"docSource.feature.attributes.OWNERLASTN" : "Stump",  
"docSource.feature.attributes.HOUSENO" : "10003",  
"docSource.feature.attributes.STTYPE" : "DR"  
},  
"highlight" : {  
"docSource.feature.attributes.OWNERFULLN" : [ "usana  
_Stump_ " ]  
}  
}, ...............

---

<div class="post-metadata">

**Author:** ![jmurdoch](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jmurdoch](https://discuss.elastic.co/u/jmurdoch)\
**Post date:** [July 28, 2011, 11:22pm UTC](https://discuss.elastic.co/t/highlights-are-truncated/4993/2 "2011-07-28T23:22:19Z")

</div>

I should mention that this appears to be the case for both versions  
0.17.1 and 0.17.2.

Thanks!

On Jul 28, 4:20 pm, DeepBlueSomewhere [jv.murd...@gmail.com](mailto:jv.murd...@gmail.com) wrote:

> It appears that the results returned from a search query are  
> truncating the contents of highlighted field. Am I doing something  
> incorrectly here? Notice how the 'S' of Susana is truncated off in  
> the highlight of the OWNERFULLN field.
> 
> Thanks in advance!
> 
> Query:
> 
> {  
> "query" : {  
> "query\_string" : {  
> "query" : "Stump"  
> }  
> },  
> "fields" : ["\*"],  
> "highlight" : {  
> "fields" : {  
> "docSource.feature.attributes.OWNERFULLN" : {  
> "fragment\_size" : 100  
> }  
> }  
> }
> 
> }
> 
> Result:
> 
> {  
> "took" : 16,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 6,  
> "max\_score" : 1.4052091,  
> "hits" : [ {  
> "\_index" : "blah",  
> "_type" : "blahblah",  
> "id" : "-1668604027_-2041742376\_\_261713",  
> "\_score" : 1.4052091,  
> "fields" : {  
> "docSource.feature.attributes.OWNERFULLN" : "Susana Stump",  
> "docLastCrawlDate" : "2011-07-25T13:52:04.000Z",  
> "docSource.feature.attributes.OWNERFIRST" : "Susana",  
> "docSource.feature.attributes.ZIPCODE" : "28216",  
> "docSource.feature.attributes.SHAPE\_Length" :  
> 234.4772918513361,  
> "docSource.feature.attributes.LANDVALUE" : 30000.0,  
> "docSource.feature.attributes.STNAMEFULL" : "10003 Lomax Ridge  
> DR",  
> "docSource.feature.attributes.OWNERLASTN" : "Stump",  
> "docSource.feature.attributes.HOUSENO" : "10003",  
> "docSource.feature.attributes.STTYPE" : "DR"  
> },  
> "highlight" : {  
> "docSource.feature.attributes.OWNERFULLN" : [ "usana  
> _Stump_ " ]  
> }  
> }, ...............

---

<div class="post-metadata">

**Author:** ![Nicolas\_Lalevee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicolas_lalevee/32/2892_2.png) [@Nicolas\_Lalevee](https://discuss.elastic.co/u/Nicolas_Lalevee)\
**Post date:** [July 31, 2011, 10:12am UTC](https://discuss.elastic.co/t/highlights-are-truncated/4993/3 "2011-07-31T10:12:32Z")

</div>

The Lucene highlighter is not very smart at how to choose the fragment to highlight.  
My solution was to not fragment and do the split myself on the client side.  
Further reading: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting.html)  
see number\_of\_fragments, I've set it to 0.

Nicolas

Le 29 juil. 2011 à 01:22, DeepBlueSomewhere a écrit :

> I should mention that this appears to be the case for both versions  
> 0.17.1 and 0.17.2.
> 
> Thanks!
> 
> On Jul 28, 4:20 pm, DeepBlueSomewhere [jv.murd...@gmail.com](mailto:jv.murd...@gmail.com) wrote:
> 
> > It appears that the results returned from a search query are  
> > truncating the contents of highlighted field. Am I doing something  
> > incorrectly here? Notice how the 'S' of Susana is truncated off in  
> > the highlight of the OWNERFULLN field.
> > 
> > Thanks in advance!
> > 
> > Query:
> > 
> > {  
> > "query" : {  
> > "query\_string" : {  
> > "query" : "Stump"  
> > }  
> > },  
> > "fields" : ["\*"],  
> > "highlight" : {  
> > "fields" : {  
> > "docSource.feature.attributes.OWNERFULLN" : {  
> > "fragment\_size" : 100  
> > }  
> > }  
> > }
> > 
> > }
> > 
> > Result:
> > 
> > {  
> > "took" : 16,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 6,  
> > "max\_score" : 1.4052091,  
> > "hits" : [ {  
> > "\_index" : "blah",  
> > "_type" : "blahblah",  
> > "id" : "-1668604027_-2041742376\_\_261713",  
> > "\_score" : 1.4052091,  
> > "fields" : {  
> > "docSource.feature.attributes.OWNERFULLN" : "Susana Stump",  
> > "docLastCrawlDate" : "2011-07-25T13:52:04.000Z",  
> > "docSource.feature.attributes.OWNERFIRST" : "Susana",  
> > "docSource.feature.attributes.ZIPCODE" : "28216",  
> > "docSource.feature.attributes.SHAPE\_Length" :  
> > 234.4772918513361,  
> > "docSource.feature.attributes.LANDVALUE" : 30000.0,  
> > "docSource.feature.attributes.STNAMEFULL" : "10003 Lomax Ridge  
> > DR",  
> > "docSource.feature.attributes.OWNERLASTN" : "Stump",  
> > "docSource.feature.attributes.HOUSENO" : "10003",  
> > "docSource.feature.attributes.STTYPE" : "DR"  
> > },  
> > "highlight" : {  
> > "docSource.feature.attributes.OWNERFULLN" : [ "usana  
> > _Stump_ " ]  
> > }  
> > }, ...............

---

<div class="post-metadata">

**Author:** ![jmurdoch](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jmurdoch](https://discuss.elastic.co/u/jmurdoch)\
**Post date:** [August 1, 2011, 4:02pm UTC](https://discuss.elastic.co/t/highlights-are-truncated/4993/4 "2011-08-01T16:02:08Z")

</div>

Thanks for the tip, Nicolas!  
That will work just fine.

Cheers,  
Jen

On Jul 31, 3:12 am, Nicolas Lalevée [nicolas.lale...@hibnet.org](mailto:nicolas.lale...@hibnet.org)  
wrote:

> The Lucene highlighter is not very smart at how to choose the fragment to highlight.  
> My solution was to not fragment and do the split myself on the client side.  
> Further reading:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting)....  
> see number\_of\_fragments, I've set it to 0.
> 
> Nicolas
> 
> Le 29 juil. 2011 à 01:22, DeepBlueSomewhere a écrit :
> 
> > I should mention that this appears to be the case for both versions  
> > 0.17.1 and 0.17.2.
> 
> > Thanks!
> 
> > On Jul 28, 4:20 pm, DeepBlueSomewhere [jv.murd...@gmail.com](mailto:jv.murd...@gmail.com) wrote:
> > 
> > > It appears that the results returned from a search query are  
> > > truncating the contents of highlighted field. Am I doing something  
> > > incorrectly here? Notice how the 'S' of Susana is truncated off in  
> > > the highlight of the OWNERFULLN field.
> 
> > > Thanks in advance!
> 
> > > Query:
> 
> > > {  
> > > "query" : {  
> > > "query\_string" : {  
> > > "query" : "Stump"  
> > > }  
> > > },  
> > > "fields" : ["\*"],  
> > > "highlight" : {  
> > > "fields" : {  
> > > "docSource.feature.attributes.OWNERFULLN" : {  
> > > "fragment\_size" : 100  
> > > }  
> > > }  
> > > }
> 
> > > }
> 
> > > Result:
> 
> > > {  
> > > "took" : 16,  
> > > "timed\_out" : false,  
> > > "\_shards" : {  
> > > "total" : 5,  
> > > "successful" : 5,  
> > > "failed" : 0  
> > > },  
> > > "hits" : {  
> > > "total" : 6,  
> > > "max\_score" : 1.4052091,  
> > > "hits" : [ {  
> > > "\_index" : "blah",  
> > > "_type" : "blahblah",  
> > > "id" : "-1668604027_-2041742376\_\_261713",  
> > > "\_score" : 1.4052091,  
> > > "fields" : {  
> > > "docSource.feature.attributes.OWNERFULLN" : "Susana Stump",  
> > > "docLastCrawlDate" : "2011-07-25T13:52:04.000Z",  
> > > "docSource.feature.attributes.OWNERFIRST" : "Susana",  
> > > "docSource.feature.attributes.ZIPCODE" : "28216",  
> > > "docSource.feature.attributes.SHAPE\_Length" :  
> > > 234.4772918513361,  
> > > "docSource.feature.attributes.LANDVALUE" : 30000.0,  
> > > "docSource.feature.attributes.STNAMEFULL" : "10003 Lomax Ridge  
> > > DR",  
> > > "docSource.feature.attributes.OWNERLASTN" : "Stump",  
> > > "docSource.feature.attributes.HOUSENO" : "10003",  
> > > "docSource.feature.attributes.STTYPE" : "DR"  
> > > },  
> > > "highlight" : {  
> > > "docSource.feature.attributes.OWNERFULLN" : [ "usana  
> > > _Stump_ " ]  
> > > }  
> > > }, ...............

---

<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 6, 2017, 3:58am UTC](https://discuss.elastic.co/t/highlights-are-truncated/4993/5 "2017-07-06T03:58:40Z")

</div>


