# Returning text snippet containing highlighted hits

**URL:** https://discuss.elastic.co/t/returning-text-snippet-containing-highlighted-hits/5864
**Category:** Elasticsearch
**Created:** [November 14, 2011, 12:28pm UTC](https://discuss.elastic.co/t/returning-text-snippet-containing-highlighted-hits/5864 "2011-11-14T12:28:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Robert\_Grundler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robert_grundler/32/3068_2.png) [@Robert\_Grundler](https://discuss.elastic.co/u/Robert_Grundler)
#### Post date: [November 14, 2011, 12:28pm UTC](https://discuss.elastic.co/t/returning-text-snippet-containing-highlighted-hits/5864/1 "2011-11-14T12:28:50Z")

</div>

Hi,

we're indexing tables from a relational database where some fields have a  
rather large amount of text. What i'm trying to implement is some sort of  
"snippet preview" to show part of the text which contains the highlighted  
match.

Is there some way to retrieve this kind of result directly from  
elasticsearch?

regards

-robert

---

<div class="post-metadata">

### Author: ![Mauricio\_Alarcon](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mauricio\_Alarcon](https://discuss.elastic.co/u/Mauricio_Alarcon)
#### Post date: [November 14, 2011, 3:32pm UTC](https://discuss.elastic.co/t/returning-text-snippet-containing-highlighted-hits/5864/2 "2011-11-14T15:32:55Z")

</div>

Hi Robert

just use the highlight option, it has neat options like the tags to  
use, the size of the fragment and the number of fragments to return

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

~M

On Nov 14, 7:28 am, Robert Gründler [r.gruend...@gmail.com](mailto:r.gruend...@gmail.com) wrote:

> Hi,
> 
> we're indexing tables from a relational database where some fields have a  
> rather large amount of text. What i'm trying to implement is some sort of  
> "snippet preview" to show part of the text which contains the highlighted  
> match.
> 
> Is there some way to retrieve this kind of result directly from  
> elasticsearch?
> 
> regards
> 
> -robert

---

<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:48am UTC](https://discuss.elastic.co/t/returning-text-snippet-containing-highlighted-hits/5864/3 "2017-07-06T03:48:44Z")

</div>


