Solr's copyField equivalent in ElasticSearch

Hello team,
We are migrating from Solr to ES. Please let me know if there is an equivalent of copyField in ES.

Basically for the below Solr code, this was done to enable date range searches on lastUpdateDate I need an equivalent in ES. Or let me know if we can enable date range searches in a different way

<copyField source="updateDate" dest="lastUpdateDate"/>

<field name="updateDate" type="date" stored="true" indexed="true" />
<field name="lastUpdateDate" stored="true" indexed="true" type="date_range" />

Hi @nn14

The "copy_to" can help you?

1 Like

Hi @RabBit_BR.

I tried and this is what I have

				"lastUpdateDate": {
					"type": "date"
				"updateDate": {
					"type": "date",
					"copy_to": "lastUpdateDate"

I believe this copy_to field will not appear in _source field as per the documentation. If I need to show all the fields in the response including the copy field, how should I query in the index?

Look this:

Set store:true for lastUpdateDate field.
In query use "stored_fields": ["lastUpdateDate"].

Hi @RabBit_BR , thanks I can now see the copied field using the query you shared. I am using the below Java code to retrieve all the fields from the index. This returns all fields from _source. How can I include copied fields in the same response. Is this something which you can provide some pointers?

        SearchRequest searchRequest = new SearchRequest(indexName);
        SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();

        sourceBuilder.query(new NativeSearchQueryBuilder()

SearchResponse response =, RequestOptions.DEFAULT);

Try this:


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