# How to create teasers in elastic search like in FAST esp

**URL:** <https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027>\
**Category:** Elasticsearch\
**Created:** [March 21, 2016, 5:23pm UTC](https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027 "2016-03-21T17:23:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YaroDakyau](https://avatars.discourse-cdn.com/v4/letter/y/258eb7/32.png) [@YaroDakyau](https://discuss.elastic.co/u/YaroDakyau)\
**Post date:** [March 21, 2016, 5:23pm UTC](https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027/1 "2016-03-21T17:23:58Z")

</div>

A search in fast which includes highlight field as shown bellow:  
{  
"query" : {

```
  "multi_match" : {
        "query" : "quick brown fox",
       ....
 }

```

}  
"highlight:" {  
"fields" : {  
"field.summary"  
}  
}  
}

will give a result that will have a highlight section:

"highlight" : {  
"field.summary" : [  
"some text _quick_ more text",  
"more text aa _brown_ dll",  
"text1 text3 _brown_"  
]  
}

I want a concatenation of the array entries returned and also a way to specify the maximum number of characters in the generation string.

FAST esp can do that by specifying juniper configurations.

Anyone have any idea on how to accomplish this?

Thanks.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 21, 2016, 7:31pm UTC](https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027/2 "2016-03-21T19:31:09Z")

</div>

Read the documentation about fragment numbers and sizes

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#\_highlighted\_fragments](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#_highlighted_fragments)

then you can achieve highlighting like in FAST ESP.

---

<div class="post-metadata">

**Author:** ![YaroDakyau](https://avatars.discourse-cdn.com/v4/letter/y/258eb7/32.png) [@YaroDakyau](https://discuss.elastic.co/u/YaroDakyau)\
**Post date:** [April 1, 2016, 8:41am UTC](https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027/3 "2016-04-01T08:41:03Z")

</div>

I have already used that but want I want to achieve is not to have a variable length teaser. For example I could set the max number of fragments to the 5 and the fragment size to 100 as I want to get a teaser of 500 characters in total. Now it's possible that I get returned only 3 fragments (all with 100 character) - So is there a way to dynamically adjust it to return the 3 fragments but with 150 characters? The Juniper engine in FAST ESP allows for setting the maximum size of characters produced in the final teaser.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [April 1, 2016, 8:58am UTC](https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027/4 "2016-04-01T08:58:45Z")

</div>

I think for mimicking this "auto sizing fragments to a static total size" feature it would require digging into the open source code of the highlighter and add this feature...

A possible starting point is

[https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java](https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java)

---

<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 5, 2017, 11:03pm UTC](https://discuss.elastic.co/t/how-to-create-teasers-in-elastic-search-like-in-fast-esp/45027/5 "2017-07-05T23:03:23Z")

</div>


