# Highlight in the field response

**URL:** <https://discuss.elastic.co/t/highlight-in-the-field-response/334955>\
**Category:** Elasticsearch\
**Created:** [June 1, 2023, 10:25am UTC](https://discuss.elastic.co/t/highlight-in-the-field-response/334955 "2023-06-01T10:25:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirtash](https://avatars.discourse-cdn.com/v4/letter/k/a8b319/32.png) [@Kirtash](https://discuss.elastic.co/u/Kirtash)\
**Post date:** [June 1, 2023, 10:25am UTC](https://discuss.elastic.co/t/highlight-in-the-field-response/334955/1 "2023-06-01T10:25:56Z")

</div>

Good morning,

I have an application that read the results from my query in elasticsearch and I take all the fields of the response and after it, I put it in a windows form for the user.

Now I would like remark the part when I have a result in Highlight, but my question is, is it possible that the remarks (\< em \>) appears in the field response?

In negative case..I'm doing a loop in Highlight searching if exists in the document to replace it but is inefficient ☹

Thanks for the help!!

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [June 2, 2023, 10:24am UTC](https://discuss.elastic.co/t/highlight-in-the-field-response/334955/2 "2023-06-02T10:24:52Z")

</div>

Hi @Kirtash,

Are you making use of the [Highlighting](https://www.elastic.co/guide/en/elasticsearch/reference/current/highlighting.html) capability of Elasticsearch? It should return the `<em>` fields in the right place for you.

---

<div class="post-metadata">

**Author:** ![Kirtash](https://avatars.discourse-cdn.com/v4/letter/k/a8b319/32.png) [@Kirtash](https://discuss.elastic.co/u/Kirtash)\
**Post date:** [June 5, 2023, 6:51am UTC](https://discuss.elastic.co/t/highlight-in-the-field-response/334955/3 "2023-06-05T06:51:13Z")

</div>

Hi @carly.richmond,

Yes, but It returns these results outside of the source. For example, If I make a query to highlighting the word "ande" in a index that I have the name "Alexander", I will receive the next:

```auto
"_source": {
          "info": {
            "name": "ALEXANDER",
},
"highlight": {
          "info.name": [
            "ALEX<em>ANDER</em>"
          ]
 }

```

I would like that this structure with the tag _coud be in the source field_

 

_Thanks and sorry for my bad explanation._

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [June 5, 2023, 10:07am UTC](https://discuss.elastic.co/t/highlight-in-the-field-response/334955/4 "2023-06-05T10:07:24Z")

</div>

I don't believe you can include it in the source field. Can you give an example of what you mean by the negative case that you need to loop for?

---

<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 3, 2023, 10:07am UTC](https://discuss.elastic.co/t/highlight-in-the-field-response/334955/5 "2023-07-03T10:07:35Z")

</div>

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