# Highlight whole sentence

**URL:** <https://discuss.elastic.co/t/highlight-whole-sentence/8838>\
**Category:** Elasticsearch\
**Created:** [August 23, 2012, 10:15pm UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838 "2012-08-23T22:15:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guram\_Kajaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guram_kajaia/32/2749_2.png) [@Guram\_Kajaia](https://discuss.elastic.co/u/Guram_Kajaia)\
**Post date:** [August 23, 2012, 10:15pm UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/1 "2012-08-23T22:15:41Z")

</div>

Hello guys.

Please run this curl recreation.  
[https://gist.github.com/3442578](https://gist.github.com/3442578)

As you can see, i'm search work 'elasticsearch' in text : ElasticSearch can  
be used to search all 1kind of documents. It provides a scalable search  
solution, has near real-time search and support for multitenancy.[5]  
ElasticSearch is distributed, which means that indices can be divided into  
shards and each shard can have zero or more replicas. Each node hosts one  
or more shards, and acts as a coordinator to delegate operations to the  
correct shard(s). Rebalancing and routing are done automatically.

and highlighted text returned:  
"_ElasticSearch_ can be used to search all 1kind of documents. It  
provides a scalable search solution",  
", has near real-time search and support for multitenancy.[5]  
_ElasticSearch_ is distributed, which"

Is it possible to highlight text where matched text is between dots ? I  
want to get this highlight :  
"_ElasticSearch_ can be used to search all 1kind of documents.",  
"_ElasticSearch_ is distributed, which means that indices can be  
divided into shards and each shard can have zero or more replicas."

Thanks.  
GuriK.

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 24, 2012, 1:43am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/2 "2012-08-24T01:43:05Z")

</div>

Hi GuriK,

Did you look at: [http://www.elasticsearch.org/guide/reference/api/search/highlighting.html](http://www.elasticsearch.org/guide/reference/api/search/highlighting.html) ?  
I think that the last part answers to your needs:  
Boundary Characters

When highlighting a field that is mapped with term vectors, boundary\_chars can be configured to define what constitutes a boundary for highlighting. Its a single string with each boundary character defined in it. It defaults to .,!? \t\n.

The boundary\_max\_size allows to control how far to look for boundary characters, and defaults to 20.

I never played with it myself. But I hope this could help.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 24 août 2012 à 00:15, GuriK [guram.kajaia@gmail.com](mailto:guram.kajaia@gmail.com) a écrit :

Hello guys.

Please run this curl recreation.  
[https://gist.github.com/3442578](https://gist.github.com/3442578)

As you can see, i'm search work 'elasticsearch' in text : ElasticSearch can be used to search all 1kind of documents. It provides a scalable search solution, has near real-time search and support for multitenancy.[5] ElasticSearch is distributed, which means that indices can be divided into shards and each shard can have zero or more replicas. Each node hosts one or more shards, and acts as a coordinator to delegate operations to the correct shard(s). Rebalancing and routing are done automatically.

and highlighted text returned:  
"_ElasticSearch_ can be used to search all 1kind of documents. It provides a scalable search solution",  
", has near real-time search and support for multitenancy.[5] _ElasticSearch_ is distributed, which"

Is it possible to highlight text where matched text is between dots ? I want to get this highlight :  
"_ElasticSearch_ can be used to search all 1kind of documents.",  
"_ElasticSearch_ is distributed, which means that indices can be divided into shards and each shard can have zero or more replicas."

Thanks.  
GuriK.

--

--

---

<div class="post-metadata">

**Author:** ![Guram\_Kajaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guram_kajaia/32/2749_2.png) [@Guram\_Kajaia](https://discuss.elastic.co/u/Guram_Kajaia)\
**Post date:** [August 24, 2012, 8:35am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/3 "2012-08-24T08:35:33Z")

</div>

Hi David.

I mapped my field like this "message" : { "type" : "string", "term\_vector"  
: "with\_positions\_offsets"} but results is still not what i wanted.  
All i want to do is to get text between dots no matter how long that text  
will be.

- 

GuriK

On Fri, Aug 24, 2012 at 5:43 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Hi GuriK,
> 
> Did you look at:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting.html)?  
> I think that the last part answers to your needs:  
> Boundary Characters
> 
> When highlighting a field that is mapped with term vectors, boundary\_chars can  
> be configured to define what constitutes a boundary for highlighting. Its a  
> single string with each boundary character defined in it. It defaults to .,!?  
> \t\n.
> 
> The boundary\_max\_size allows to control how far to look for boundary  
> characters, and defaults to 20.
> 
> I never played with it myself. But I hope this could help.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 24 août 2012 à 00:15, GuriK [guram.kajaia@gmail.com](mailto:guram.kajaia@gmail.com) a écrit :
> 
> Hello guys.
> 
> Please run this curl recreation.  
> [https://gist.github.com/3442578](https://gist.github.com/3442578)
> 
> As you can see, i'm search work 'elasticsearch' in text : Elasticsearch  
> can be used to search all 1kind of documents. It provides a scalable search  
> solution, has near real-time search and support for multitenancy.[5]  
> Elasticsearch is distributed, which means that indices can be divided into  
> shards and each shard can have zero or more replicas. Each node hosts one  
> or more shards, and acts as a coordinator to delegate operations to the  
> correct shard(s). Rebalancing and routing are done automatically.
> 
> and highlighted text returned:  
> "_Elasticsearch_ can be used to search all 1kind of documents. It  
> provides a scalable search solution",  
> ", has near real-time search and support for multitenancy.[5]  
> _Elasticsearch_ is distributed, which"
> 
> Is it possible to highlight text where matched text is between dots ? I  
> want to get this highlight :  
> "_Elasticsearch_ can be used to search all 1kind of documents.",  
> "_Elasticsearch_ is distributed, which means that indices can be  
> divided into shards and each shard can have zero or more replicas."
> 
> Thanks.  
> GuriK.
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 24, 2012, 1:04pm UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/4 "2012-08-24T13:04:10Z")

</div>

Did you set  
boundary\_max\_size to 0

## When highlighting?

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 24 août 2012 à 10:35, Guram Kajaia [guram.kajaia@gmail.com](mailto:guram.kajaia@gmail.com) a écrit :

> Hi David.
> 
> I mapped my field like this "message" : { "type" : "string", "term\_vector" : "with\_positions\_offsets"} but results is still not what i wanted.  
> All i want to do is to get text between dots no matter how long that text will be.
> 
> - 
> 
> GuriK
> 
> On Fri, Aug 24, 2012 at 5:43 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Hi GuriK,
> 
> Did you look at: [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting.html) ?  
> I think that the last part answers to your needs:  
> Boundary Characters
> 
> When highlighting a field that is mapped with term vectors, boundary\_chars can be configured to define what constitutes a boundary for highlighting. Its a single string with each boundary character defined in it. It defaults to .,!? \t\n.
> 
> The boundary\_max\_size allows to control how far to look for boundary characters, and defaults to 20.
> 
> I never played with it myself. But I hope this could help.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 24 août 2012 à 00:15, GuriK [guram.kajaia@gmail.com](mailto:guram.kajaia@gmail.com) a écrit :
> 
> Hello guys.
> 
> Please run this curl recreation.  
> [https://gist.github.com/3442578](https://gist.github.com/3442578)
> 
> As you can see, i'm search work 'elasticsearch' in text : Elasticsearch can be used to search all 1kind of documents. It provides a scalable search solution, has near real-time search and support for multitenancy.[5] Elasticsearch is distributed, which means that indices can be divided into shards and each shard can have zero or more replicas. Each node hosts one or more shards, and acts as a coordinator to delegate operations to the correct shard(s). Rebalancing and routing are done automatically.
> 
> and highlighted text returned:  
> "_Elasticsearch_ can be used to search all 1kind of documents. It provides a scalable search solution",  
> ", has near real-time search and support for multitenancy.[5] _Elasticsearch_ is distributed, which"
> 
> Is it possible to highlight text where matched text is between dots ? I want to get this highlight :  
> "_Elasticsearch_ can be used to search all 1kind of documents.",  
> "_Elasticsearch_ is distributed, which means that indices can be divided into shards and each shard can have zero or more replicas."
> 
> Thanks.  
> GuriK.
> 
> --
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Guram\_Kajaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guram_kajaia/32/2749_2.png) [@Guram\_Kajaia](https://discuss.elastic.co/u/Guram_Kajaia)\
**Post date:** [August 24, 2012, 1:29pm UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/5 "2012-08-24T13:29:28Z")

</div>

Yes.  
Result is the same ...

On Fri, Aug 24, 2012 at 5:04 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Did you set  
> boundary\_max\_size to 0
> 
> ## When highlighting?
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 24 août 2012 à 10:35, Guram Kajaia [guram.kajaia@gmail.com](mailto:guram.kajaia@gmail.com) a écrit :
> 
> Hi David.
> 
> I mapped my field like this "message" : { "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"} but results is still not what  
> i wanted.  
> All i want to do is to get text between dots no matter how long that text  
> will be.
> 
> - 
> 
> GuriK
> 
> On Fri, Aug 24, 2012 at 5:43 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Hi GuriK,
> > 
> > Did you look at:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting.html)?  
> > I think that the last part answers to your needs:  
> > Boundary Characters
> > 
> > When highlighting a field that is mapped with term vectors,  
> > boundary\_chars can be configured to define what constitutes a boundary  
> > for highlighting. Its a single string with each boundary character defined  
> > in it. It defaults to .,!? \t\n.
> > 
> > The boundary\_max\_size allows to control how far to look for boundary  
> > characters, and defaults to 20.
> > 
> > I never played with it myself. But I hope this could help.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 24 août 2012 à 00:15, GuriK [guram.kajaia@gmail.com](mailto:guram.kajaia@gmail.com) a écrit :
> > 
> > Hello guys.
> > 
> > Please run this curl recreation.  
> > [https://gist.github.com/3442578](https://gist.github.com/3442578)
> > 
> > As you can see, i'm search work 'elasticsearch' in text : Elasticsearch  
> > can be used to search all 1kind of documents. It provides a scalable search  
> > solution, has near real-time search and support for multitenancy.[5]  
> > Elasticsearch is distributed, which means that indices can be divided into  
> > shards and each shard can have zero or more replicas. Each node hosts one  
> > or more shards, and acts as a coordinator to delegate operations to the  
> > correct shard(s). Rebalancing and routing are done automatically.
> > 
> > and highlighted text returned:  
> > "_Elasticsearch_ can be used to search all 1kind of documents. It  
> > provides a scalable search solution",  
> > ", has near real-time search and support for multitenancy.[5]  
> > _Elasticsearch_ is distributed, which"
> > 
> > Is it possible to highlight text where matched text is between dots ? I  
> > want to get this highlight :  
> > "_Elasticsearch_ can be used to search all 1kind of documents.",  
> > "_Elasticsearch_ is distributed, which means that indices can be  
> > divided into shards and each shard can have zero or more replicas."
> > 
> > Thanks.  
> > GuriK.
> > 
> > --
> > 
> > --
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Nick\_Dunn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_dunn/32/2315_2.png) [@Nick\_Dunn](https://discuss.elastic.co/u/Nick_Dunn)\
**Post date:** [August 25, 2012, 6:23am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/6 "2012-08-25T06:23:53Z")

</div>

I don't understand the "between dots" part; I can't see the pattern between the actual output and the desired output. Are you saying you always want the highlighted (wrapped with EM) to be the first characters of the highlight excerpt, and not midway within the string?

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 25, 2012, 9:08am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/7 "2012-08-25T09:08:31Z")

</div>

I think he wants to highlight a full sentence and not 5 words before and after the highlighted term.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 25 août 2012 à 08:23, Nick Dunn [nick@nick-dunn.co.uk](mailto:nick@nick-dunn.co.uk) a écrit :

I don't understand the "between dots" part; I can't see the pattern between the actual output and the desired output. Are you saying you always want the highlighted (wrapped with EM) to be the first characters of the highlight excerpt, and not midway within the string?

--

--

---

<div class="post-metadata">

**Author:** ![Guram\_Kajaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guram_kajaia/32/2749_2.png) [@Guram\_Kajaia](https://discuss.elastic.co/u/Guram_Kajaia)\
**Post date:** [August 25, 2012, 7:29pm UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/8 "2012-08-25T19:29:17Z")

</div>

You're right David. I don't want to specify how many words to highlight  
before or/and after matched text. I just want full sentence which includes  
matched text.

On Sat, Aug 25, 2012 at 1:08 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> I think he wants to highlight a full sentence and not 5 words before and  
> after the highlighted term.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 25 août 2012 à 08:23, Nick Dunn [nick@nick-dunn.co.uk](mailto:nick@nick-dunn.co.uk) a écrit :
> 
> I don't understand the "between dots" part; I can't see the pattern  
> between the actual output and the desired output. Are you saying you always  
> want the highlighted (wrapped with EM) to be the first characters of the  
> highlight excerpt, and not midway within the string?
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Nick\_Dunn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_dunn/32/2315_2.png) [@Nick\_Dunn](https://discuss.elastic.co/u/Nick_Dunn)\
**Post date:** [August 26, 2012, 4:04am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/9 "2012-08-26T04:04:24Z")

</div>

Sounds like this is a task for your own application logic to parse and extract in my opinion.

--

---

<div class="post-metadata">

**Author:** ![Guram\_Kajaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guram_kajaia/32/2749_2.png) [@Guram\_Kajaia](https://discuss.elastic.co/u/Guram_Kajaia)\
**Post date:** [August 27, 2012, 11:45am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/10 "2012-08-27T11:45:31Z")

</div>

Yes, maybe...  
is any way to write plugin for elasticsearch which will do what i want ? in  
this case highlighting whole sentence...

On Sun, Aug 26, 2012 at 8:04 AM, Nick Dunn [nick@nick-dunn.co.uk](mailto:nick@nick-dunn.co.uk) wrote:

> Sounds like this is a task for your own application logic to parse and  
> extract in my opinion.
> 
> --

--

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)\
**Post date:** [August 29, 2012, 6:23am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/11 "2012-08-29T06:23:27Z")

</div>

This is really a problem of plugging in a different Fragmenter  
[http://lucene.apache.org/core/3\_6\_0/api/all/index.html](http://lucene.apache.org/core/3_6_0/api/all/index.html)  
Which I do NOT believe is an extension point in ES.

-Paul

On 8/27/2012 4:45 AM, Guram Kajaia wrote:

> Yes, maybe...  
> is any way to write plugin for elasticsearch which will do what i want  
> ? in this case highlighting whole sentence...
> 
> On Sun, Aug 26, 2012 at 8:04 AM, Nick Dunn \<[nick@nick-dunn.co.uk](mailto:nick@nick-dunn.co.uk)  
> [mailto:nick@nick-dunn.co.uk](mailto:nick@nick-dunn.co.uk)\> wrote:
> 
> ```
> Sounds like this is a task for your own application logic to parse
> and extract in my opinion.
> 
> --
> 
> ```
> 
> --

--

---

<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:14am UTC](https://discuss.elastic.co/t/highlight-whole-sentence/8838/12 "2017-07-06T03:14:46Z")

</div>


