# Controlling highlight fragments

**URL:** <https://discuss.elastic.co/t/controlling-highlight-fragments/3358>\
**Category:** Elasticsearch\
**Created:** [September 22, 2010, 7:02pm UTC](https://discuss.elastic.co/t/controlling-highlight-fragments/3358 "2010-09-22T19:02:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pzelnip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pzelnip/32/3251_2.png) [@pzelnip](https://discuss.elastic.co/u/pzelnip)\
**Post date:** [September 22, 2010, 7:02pm UTC](https://discuss.elastic.co/t/controlling-highlight-fragments/3358/1 "2010-09-22T19:02:33Z")

</div>

I think this is currently already an open issue ([http://github.com/](http://github.com/)  
elasticsearch/elasticsearch/issues/#issue/307), but I want to make  
sure I'm not missing something that is currently available in  
ElasticSearch.

Is it possible to control how a highlight's fragments are created? As  
I read it, the API only allows one to specify the fragment size (in  
characters), but there's no ability to specify where in a source field  
that fragment should start or end (say for example at the start or end  
of a sentence in a document).

Or am I missing something?

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [September 22, 2010, 7:08pm UTC](https://discuss.elastic.co/t/controlling-highlight-fragments/3358/2 "2010-09-22T19:08:26Z")

</div>

You are correct. It is not possible now. However, there is new feature in  
master that allows retrieval of whole field content with highlighted tags.

Dne 2010 9 22 21:02 "Adam Parkin" [pzelnip@gmail.com](mailto:pzelnip@gmail.com) napsal(a):

> I think this is currently already an open issue ([http://github.com/](http://github.com/)  
> elasticsearch/elasticsearch/issues/#issue/307), but I want to make  
> sure I'm not missing something that is currently available in  
> Elasticsearch.
> 
> Is it possible to control how a highlight's fragments are created? As  
> I read it, the API only allows one to specify the fragment size (in  
> characters), but there's no ability to specify where in a source field  
> that fragment should start or end (say for example at the start or end  
> of a sentence in a document).
> 
> Or am I missing something?

---

<div class="post-metadata">

**Author:** ![pzelnip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pzelnip/32/3251_2.png) [@pzelnip](https://discuss.elastic.co/u/pzelnip)\
**Post date:** [September 22, 2010, 7:25pm UTC](https://discuss.elastic.co/t/controlling-highlight-fragments/3358/3 "2010-09-22T19:25:59Z")

</div>

And how do I do that (retrieve whole field with highlighted tags)?

Thanks!

On Sep 22, 12:08 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> You are correct. It is not possible now. However, there is new feature in  
> master that allows retrieval of whole field content with highlighted tags.
> 
> Dne 2010 9 22 21:02 "Adam Parkin" [pzel...@gmail.com](mailto:pzel...@gmail.com) napsal(a):
> 
> > I think this is currently already an open issue ([http://github.com/](http://github.com/)  
> > elasticsearch/elasticsearch/issues/#issue/307), but I want to make  
> > sure I'm not missing something that is currently available in  
> > Elasticsearch.
> 
> > Is it possible to control how a highlight's fragments are created? As  
> > I read it, the API only allows one to specify the fragment size (in  
> > characters), but there's no ability to specify where in a source field  
> > that fragment should start or end (say for example at the start or end  
> > of a sentence in a document).
> 
> > Or am I missing something?

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [September 22, 2010, 7:39pm UTC](https://discuss.elastic.co/t/controlling-highlight-fragments/3358/4 "2010-09-22T19:39:19Z")

</div>

By setting number\_of\_fragments to 0. You can check javaDoc in the following  
commit

> <https://github.com/elastic/elasticsearch/blob/243b7455e8578c9bdc401beb0c7e010c542d4a8e/modules/elasticsearch/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java>

It is also possible to override highlight settings at each field level  
differently. HTH.  
Regards,  
Lukas

Dne 2010 9 22 21:26 "Adam Parkin" [pzelnip@gmail.com](mailto:pzelnip@gmail.com) napsal(a):  
And how do I do that (retrieve whole field with highlighted tags)?

Thanks!

On Sep 22, 12:08 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> You are correct. It is not possi...  
> Dne 2010 9 22 21:02 "Adam Parkin" [pzel...@gmail.com](mailto:pzel...@gmail.com) napsal(a):

> > I think this is currently already an open issue ([http://github.com/](http://github.com/)  
> > elasticsearch/elastics...

---

<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, 4:19am UTC](https://discuss.elastic.co/t/controlling-highlight-fragments/3358/5 "2017-07-06T04:19:04Z")

</div>


