# Highlight Fragment location

**URL:** <https://discuss.elastic.co/t/highlight-fragment-location/9100>\
**Category:** Elasticsearch\
**Created:** [September 21, 2012, 6:54pm UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100 "2012-09-21T18:54:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_3](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Andy\_3](https://discuss.elastic.co/u/Andy_3)\
**Post date:** [September 21, 2012, 6:54pm UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100/1 "2012-09-21T18:54:12Z")

</div>

I'm highlighting 100 character fragments on a relatively small text field,  
~2,000 characters.

Is it possible to know if the highlighted fragment contains the start of  
the document? The use case is displaying "..." before the fragment if it's  
not the start of the document.

Thanks for any help!

--

---

<div class="post-metadata">

**Author:** ![Robin\_Verlangen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_verlangen/32/1542_2.png) [@Robin\_Verlangen](https://discuss.elastic.co/u/Robin_Verlangen)\
**Post date:** [September 22, 2012, 12:01pm UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100/2 "2012-09-22T12:01:49Z")

</div>

You could simply compare the search query with the start of the start of  
the document? Or are you looking for some other way?

Best regards,

Robin Verlangen  
_Software engineer_  
\*  
\*  
W [http://www.robinverlangen.nl](http://www.robinverlangen.nl)  
E robin@us2.nl

[http://goo.gl/Lt7BC](http://goo.gl/Lt7BC)

Disclaimer: The information contained in this message and attachments is  
intended solely for the attention and use of the named addressee and may be  
confidential. If you are not the intended recipient, you are reminded that  
the information remains the property of the sender. You must not use,  
disclose, distribute, copy, print or rely on this e-mail. If you have  
received this message in error, please contact the sender immediately and  
irrevocably delete this message and any copies.

2012/9/21 Andy [apryor48@gmail.com](mailto:apryor48@gmail.com)

> I'm highlighting 100 character fragments on a relatively small text field,  
> ~2,000 characters.
> 
> Is it possible to know if the highlighted fragment contains the start of  
> the document? The use case is displaying "..." before the fragment if it's  
> not the start of the document.
> 
> Thanks for any help!
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Andy\_3](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Andy\_3](https://discuss.elastic.co/u/Andy_3)\
**Post date:** [September 22, 2012, 3:26pm UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100/3 "2012-09-22T15:26:41Z")

</div>

Hmm, I would first have to strip the highlight tags. That doesn't sound  
ideal. I wonder if the highlighter could just return the indexes of the  
fragment inside the field.

Maybe this isn't a common use case.  
On Sep 22, 2012 7:01 AM, "Robin Verlangen" [robin@us2.nl](mailto:robin@us2.nl) wrote:

> You could simply compare the search query with the start of the start of  
> the document? Or are you looking for some other way?
> 
> Best regards,
> 
> Robin Verlangen  
> _Software engineer_  
> \*  
> \*  
> W [http://www.robinverlangen.nl](http://www.robinverlangen.nl)  
> E robin@us2.nl
> 
> [http://goo.gl/Lt7BC](http://goo.gl/Lt7BC)
> 
> Disclaimer: The information contained in this message and attachments is  
> intended solely for the attention and use of the named addressee and may be  
> confidential. If you are not the intended recipient, you are reminded that  
> the information remains the property of the sender. You must not use,  
> disclose, distribute, copy, print or rely on this e-mail. If you have  
> received this message in error, please contact the sender immediately and  
> irrevocably delete this message and any copies.
> 
> 2012/9/21 Andy [apryor48@gmail.com](mailto:apryor48@gmail.com)
> 
> > I'm highlighting 100 character fragments on a relatively small text  
> > field, ~2,000 characters.
> > 
> > Is it possible to know if the highlighted fragment contains the start of  
> > the document? The use case is displaying "..." before the fragment if it's  
> > not the start of the document.
> > 
> > Thanks for any help!
> > 
> > --
> 
> --

--

---

<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:** [September 22, 2012, 3:55pm UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100/4 "2012-09-22T15:55:36Z")

</div>

I think that you should ask for a feature request in github :  
something like : prefix and suffix for highlight parts (with default =null)

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

Le 22 sept. 2012 à 17:26, Andy Pryor [apryor48@gmail.com](mailto:apryor48@gmail.com) a écrit :

Hmm, I would first have to strip the highlight tags. That doesn't sound ideal. I wonder if the highlighter could just return the indexes of the fragment inside the field.

Maybe this isn't a common use case.

On Sep 22, 2012 7:01 AM, "Robin Verlangen" [robin@us2.nl](mailto:robin@us2.nl) wrote:

> You could simply compare the search query with the start of the start of the document? Or are you looking for some other way?
> 
> Best regards,
> 
> Robin Verlangen  
> Software engineer
> 
> W [http://www.robinverlangen.nl](http://www.robinverlangen.nl)  
> E robin@us2.nl
> 
> Disclaimer: The information contained in this message and attachments is intended solely for the attention and use of the named addressee and may be confidential. If you are not the intended recipient, you are reminded that the information remains the property of the sender. You must not use, disclose, distribute, copy, print or rely on this e-mail. If you have received this message in error, please contact the sender immediately and irrevocably delete this message and any copies.
> 
> 2012/9/21 Andy [apryor48@gmail.com](mailto:apryor48@gmail.com)
> 
> > I'm highlighting 100 character fragments on a relatively small text field, ~2,000 characters.
> > 
> > Is it possible to know if the highlighted fragment contains the start of the document? The use case is displaying "..." before the fragment if it's not the start of the document.
> > 
> > Thanks for any help!
> > 
> > --
> 
> --

--

--

---

<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:** [September 25, 2012, 4:40am UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100/5 "2012-09-25T04:40:06Z")

</div>

Set the tags to empty strings and then you'll have the frag without and  
highlighting.  
Alternatively, use very simple tags, it doesn't have to be HTML.  
But I wouldn't worry about playing with a few string fragments. To get  
that fragment ES probably dealt with 1000s of them.

-Paul

On 9/22/2012 8:26 AM, Andy Pryor wrote:

> Hmm, I would first have to strip the highlight tags. That doesn't  
> sound ideal. I wonder if the highlighter could just return the  
> indexes of the fragment inside the field.
> 
> Maybe this isn't a common use case.
> 
> On Sep 22, 2012 7:01 AM, "Robin Verlangen" \<robin@us2.nl  
> [mailto:robin@us2.nl](mailto:robin@us2.nl)\> wrote:
> 
> ```
> You could simply compare the search query with the start of the
> start of the document? Or are you looking for some other way?
> 
> Best regards,
> 
> Robin Verlangen
> /Software engineer/
> /
> /
> W http://www.robinverlangen.nl
> E robin@us2.nl <mailto:robin@us2.nl>
> 
> <http://goo.gl/Lt7BC>
> 
> Disclaimer: The information contained in this message and
> attachments is intended solely for the attention and use of the
> named addressee and may be confidential. If you are not the
> intended recipient, you are reminded that the information remains
> the property of the sender. You must not use, disclose,
> distribute, copy, print or rely on this e-mail. If you have
> received this message in error, please contact the sender
> immediately and irrevocably delete this message and any copies.
> 
> 2012/9/21 Andy <apryor48@gmail.com <mailto:apryor48@gmail.com>>
> 
> I'm highlighting 100 character fragments on a relatively small
> text field, ~2,000 characters.
> 
> Is it possible to know if the highlighted fragment contains
> the start of the document? The use case is displaying "..."
> before the fragment if it's not the start of the document.
> 
> Thanks for any help!
> 
> -- 
> 
> -- 
> 
> ```
> 
> --

--

---

<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:11am UTC](https://discuss.elastic.co/t/highlight-fragment-location/9100/6 "2017-07-06T03:11:37Z")

</div>


