Elasticsearch highlighting: "copy_to" without "store"

I came across this post but that does not seem to help.

I have the following ES mapping:

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?

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

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

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.

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.

Sure. Put that content in another field...

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?

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. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

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