# Highlight not working when adjacent entities

**URL:** <https://discuss.elastic.co/t/highlight-not-working-when-adjacent-entities/311507>\
**Category:** Elasticsearch\
**Created:** [August 5, 2022, 10:59am UTC](https://discuss.elastic.co/t/highlight-not-working-when-adjacent-entities/311507 "2022-08-05T10:59:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![almeidajava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/almeidajava/32/48851_2.png) [@almeidajava](https://discuss.elastic.co/u/almeidajava)\
**Post date:** [August 5, 2022, 10:59am UTC](https://discuss.elastic.co/t/highlight-not-working-when-adjacent-entities/311507/1 "2022-08-05T10:59:36Z")

</div>

This happens when using mapper-annotated-text highlighter type:

eg Query:

```auto
{
    "query": {
        "ids": {
            "values": [
                "1"
            ]
        }
    },
    "_source": {
        "includes": [
            "test"
        ]
    },
    "highlight": {
        "type": "annotated",
        "highlight_query": {
            "query_string": {
                "query": "xxx",
                "fields": [
                    "test"
                ]
            }
        },
        "fields": {
            "test": {
                "number_of_fragments": 0,
                "no_match_size": 2147483647
            }
        }
    }
}

```

The response (when using highlight) skips the adjacent words, eg:

```auto
{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": "test_index",
                "_type": "_doc",
                "_id": "1",
                "_score": 1.0,
                "_source": {
                    "test": "These are the english entities [reduce](_ent_bioverb_reduce)[increase](_ent_bioverb_increase)[treat](_ent_bioverb_treat)[affect](_ent_bioverb_affect)"
                },
                "highlight": {
                    "test": [
                        "These are the english entities [reduce](_ent_bioverb_reduce)increase[treat](_ent_bioverb_treat)affect"
                    ]
                }
            }
        ]
    }
}

```

Note that highlight skipped "increase" and "affect".  
If I separate the words by adding whitespace before querying, it works. This issue only happens when there is no space between entities

---

<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:** [September 2, 2022, 11:00am UTC](https://discuss.elastic.co/t/highlight-not-working-when-adjacent-entities/311507/2 "2022-09-02T11:00:27Z")

</div>

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