# Elasticsearch Highlighting Issue with fragmentor

**URL:** <https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313>\
**Category:** Elasticsearch\
**Created:** [December 4, 2018, 8:46am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313 "2018-12-04T08:46:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [December 4, 2018, 8:46am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/1 "2018-12-04T08:46:19Z")

</div>

I am finding issues with how Elasticsearch highlights the text  
Example:

1. when using "unified" highlighter i.e.,

the results shown is :

```
"highlight": {
                    "FILE_CONTENT": [
                        "follows: \n1)Test Clause\n1.1) test 29_May\nDummy values - \nCurrency is - INR \nContract Category is - <em>Ball</em>",
                        "<em>Bearings</em> \nStart Date is - 05/31/2018 \nhgdhdrgdffggggggggggggggggggggggggggggggggggggggggggggggjerklwagggggggggggggggggggggggggggggggggg"
                    ]

```

we can see Ball and bearing are highlighted together but shown as different elements of highlight array.  
2. The same when using "fvh" highlighter solves the issue :

```
"highlight": {
        "type" : "fvh",
        
        "fields": {
            "*": {}
        }
    }

```

Highlighting for this is :

```
 "highlight": {
                    "FILE_CONTENT": [
                        "Currency is - INR \nContract Category is - <em>Ball Bearings</em> \nStart Date is - 05/31/2018 \nhgdhdrgdffgggg"
                    ]
                }

```

For some speed issues, i can not able to use Fvh highlighter. I am restricted to use unified highlighter  
According to [Elasticsearch reference module](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#specify-fragmenter) "fragmentor":"span" should solve this issue. But i am getting the same issue as when not using "fragmentor" : "span".

```
"highlight": {
        "type" : "unified",
        "fragmenter": "span",
        "fields": {
            "*": {}
        }
    }

```

The results are:

```
"highlight": {
 "FILE_CONTENT": [
                        "follows: \n1)Test Clause\n1.1) test 29_May\nDummy values - \nCurrency is - INR \nContract Category is - <em>Ball</em>",
                        "<em>Bearings</em> \nStart Date is - 05/31/2018 \nhgdhdrgdffggggggggggggggggggggggggggggggggggggggggggggggjerklwagggggggggggggggggggggggggggggggggg"
                    ] 
}

```

---

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [December 7, 2018, 11:16am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/2 "2018-12-07T11:16:06Z")

</div>

@elastic Please provide me any solution to this if it exists.

---

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [December 13, 2018, 6:44am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/3 "2018-12-13T06:44:37Z")

</div>

@elastic Could you please respond to this Query? I have waited longer than expected time for a response.

---

<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:** [December 13, 2018, 10:24am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/4 "2018-12-13T10:24:43Z")

</div>

May be @jimczi has an idea?

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [December 13, 2018, 10:59am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/5 "2018-12-13T10:59:51Z")

</div>

The unfied does not handle different fragmenter. However you can set the fragment size to -1 in order to not break sentences or set the fragment size to a value greater than the default (150 chars). We re also working on adding different fragmenter for the unified highlighter but this is not ready yet.

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [December 13, 2018, 11:06am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/6 "2018-12-13T11:06:02Z")

</div>

Sorry if you don t want to break sentences you need to set the fragment size to 0 and not -1 as I said un m'y previous comment.

---

<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:** [January 10, 2019, 11:17am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-issue-with-fragmentor/159313/7 "2019-01-10T11:17:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
