How to create teasers in elastic search like in FAST esp

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

  "multi_match" : {
        "query" : "quick brown fox",

"highlight:" {
"fields" : {

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?


Read the documentation about fragment numbers and sizes

then you can achieve highlighting like in FAST ESP.

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.

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