# Elasticsearch highlighting: "copy\_to" without "store"

**URL:** https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365
**Category:** Elasticsearch
**Created:** [May 2, 2019, 12:33pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365 "2019-05-02T12:33:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![CanardMoussant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/canardmoussant/32/45421_2.png) [@CanardMoussant](https://discuss.elastic.co/u/CanardMoussant)
#### Post date: [May 2, 2019, 12:33pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/1 "2019-05-02T12:33:50Z")

</div>

I came across [this](https://stackoverflow.com/questions/44849279/elasticsearch-highlighting-multi-match-query-on-custom-all-fields-created) post but that does not seem to help.

I have the following ES mapping:

```auto
properties {
    message {
      type: text
      analyzer: standard
      norms: false
    }
   additional {
      type: object
      dynamic: strict
      properties {
        sub {
          type: object
          properties {
            message : {
              type: text
              analyzer: standard
              index: false
              copy_to: message
            }
          }
        }
      }
    }
}

```

I am able to search through the message field and I get hits as expected if what I am looking for is in the `additional.sub.message` field. However, highlighting is always empty if what matches is in the additional field. The only way to make it work is to put `store:true` but for cost reason I would not want to set it. Is there any other way to have this working?

---

<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: [May 2, 2019, 1:03pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/2 "2019-05-02T13:03:42Z")

</div>

If you don't store the original content I don't think you can highlight it.

---

<div class="post-metadata">

### Author: ![CanardMoussant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/canardmoussant/32/45421_2.png) [@CanardMoussant](https://discuss.elastic.co/u/CanardMoussant)
#### Post date: [May 2, 2019, 1:06pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/3 "2019-05-02T13:06:19Z")

</div>

What do you mean by "original content"? Because it works fine with the `message` field only, without storing it.

---

<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: [May 2, 2019, 1:23pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/4 "2019-05-02T13:23:27Z")

</div>

But `message` is part of `_source` which is stored.  
You can compute at index time `message` field and modify the source document before you send it to the index API. So it will be stored within `_source`.

---

<div class="post-metadata">

### Author: ![CanardMoussant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/canardmoussant/32/45421_2.png) [@CanardMoussant](https://discuss.elastic.co/u/CanardMoussant)
#### Post date: [May 2, 2019, 1:45pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/5 "2019-05-02T13:45:43Z")

</div>

Oh ok I get what you meant :).  
Do you mean putting under `_source` the concatenated version? Because it is not what I want: I need the original field.

---

<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: [May 2, 2019, 2:00pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/6 "2019-05-02T14:00:29Z")

</div>

Sure. Put that content in another field...

---

<div class="post-metadata">

### Author: ![CanardMoussant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/canardmoussant/32/45421_2.png) [@CanardMoussant](https://discuss.elastic.co/u/CanardMoussant)
#### Post date: [May 2, 2019, 2:13pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/7 "2019-05-02T14:13:43Z")

</div>

But it means I need to store the same information at several places, right? There is no way that does not require additional indexing/disk space?

---

<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: [May 2, 2019, 2:50pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/8 "2019-05-02T14:50:09Z")

</div>

I don't think so.  
That being said I'm not sure I got the initial concern and what kind of problem you are trying to solve with `copy_to` here.

May be provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

---

<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: [May 30, 2019, 3:03pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-copy-to-without-store/179365/9 "2019-05-30T15:03:11Z")

</div>

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