# Varying hilightling behavior

**URL:** <https://discuss.elastic.co/t/varying-hilightling-behavior/252601>\
**Category:** Elasticsearch\
**Created:** [October 19, 2020, 7:35pm UTC](https://discuss.elastic.co/t/varying-hilightling-behavior/252601 "2020-10-19T19:35:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevo/32/77467_2.png) [@stevo](https://discuss.elastic.co/u/stevo)\
**Post date:** [October 19, 2020, 7:35pm UTC](https://discuss.elastic.co/t/varying-hilightling-behavior/252601/1 "2020-10-19T19:35:52Z")

</div>

I am seeing some unexplainable behavior with highlighting returning different responses depending on the search text. Below are two examples of nearly identical queries with different search texts. I am not sure how to explain this?

Here is query 1. Notice I am searching for "log" as an exact match in translated\_content.

```auto
        query = {
        "from": 0, "size": 5,
        '_source': ['translated_title',
                   'translated_content'],
        "query": {"bool": {
                "must": [{"query_string": {"fields": ['translated_content', 'translated_title'],
                                            "query": "translated_content.exact:log"}}
                    ]

            }
        },
        "highlight": {'fields': [{'translated_content': {'number_of_fragments': 0}},
                                 {'translated_title': {'number_of_fragments': 0}}],
                    "require_field_match": False,
                      "highlight_query": {"bool": {"must": [{"query_string": {"fields": ['translated_content', 'translated_title'],
                                            "query": "translated_content.exact:log"}}]}}},
    } 

```

The response for this is normal, as expected:

```auto
    _source: {'translated_content': 'Very log i cant even log in', 'translated_title': ''}
    highlight: {'translated_content': ['Very <em>log</em> i cant even <em>log</em> in']}
    _source: {'translated_content': 'My account log out can not log in...why?', 'translated_title': 'Good'}
    highlight: {'translated_content': ['My account <em>log</em> out can not <em>log</em> in...why?']}

```

Now here is the odd behavior. When I search for a different word, in this case 'image', I get no highlight response field. It is unclear what words return correctly with highlight and which do not.

```auto
        query = {
        "from": 0, "size": 5,
        '_source': ['translated_title',
                   'translated_content'],
        "query": {"bool": {
                "must": [{"query_string": {"fields": ['translated_content', 'translated_title'],
                                            "query": "translated_content.exact:image"}}
                    ]

            }
        },
        "highlight": {'fields': [{'translated_content': {'number_of_fragments': 0}},
                                 {'translated_title': {'number_of_fragments': 0}}],
                    "require_field_match": False,
                      "highlight_query": {"bool": {"must": [{"query_string": {"fields": ['translated_content', 'translated_title'],
                                            "query": "translated_content.exact:image"}}]}}},
    }

```

Response:

```auto
    _source: {'translated_content': 'Check this image', 'translated_title': 'Why band my id'}
highlight: None

```

---

<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:** [November 16, 2020, 7:35pm UTC](https://discuss.elastic.co/t/varying-hilightling-behavior/252601/2 "2020-11-16T19:35:57Z")

</div>

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