# Use Copy-to with different delimiters i.e "," , ";" etc

**URL:** <https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494>\
**Category:** Elasticsearch\
**Created:** [May 20, 2020, 8:50am UTC](https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494 "2020-05-20T08:50:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![farhanAamir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/farhanaamir/32/65002_2.png) [@farhanAamir](https://discuss.elastic.co/u/farhanAamir)\
**Post date:** [May 20, 2020, 8:50am UTC](https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494/1 "2020-05-20T08:50:42Z")

</div>

hi,

I am trying to concatenate two fields firstName and last name to build a field as fullName. After some R&D I have found **copy-to** feature in mapping that can help to copy fields to a certain field. But here I am trying to copy the two fields with certain delimiter e.g. ",". For instance,  
firstName: Tom  
firstName: Cruise  
fullName: Tom, Cruise

Is there any option in **copy-to** to append delimiter with field.

Thanks in advance,  
FA

---

<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 20, 2020, 9:08am UTC](https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494/2 "2020-05-20T09:08:15Z")

</div>

No. You should do that with an ingest pipeline instead. Use the [Set Processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/set-processor.html).

```auto
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "set": {
          "field": "fullName",
          "value": "{{firstName}}, {{lastName}}"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "firstName": "Tom",
        "lastName": "Cruise"
      }
    }
  ]
}

```

Gives:

```auto
{
  "docs" : [
    {
      "doc" : {
        "_index" : "_index",
        "_type" : "_doc",
        "_id" : "_id",
        "_source" : {
          "firstName" : "Tom",
          "lastName" : "Cruise",
          "fullName" : "Tom, Cruise"
        },
        "_ingest" : {
          "timestamp" : "2020-05-20T09:07:54.674741Z"
        }
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![farhanAamir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/farhanaamir/32/65002_2.png) [@farhanAamir](https://discuss.elastic.co/u/farhanAamir)\
**Post date:** [May 20, 2020, 12:04pm UTC](https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494/3 "2020-05-20T12:04:25Z")

</div>

Thanks for the quick response. I have test the suggested solution for my scenario. Let me explain the scenario a bit. I have a customer index with mapping as follows:

```auto
{
    "customer": {
        "mappings": {
            "properties": {
                "country": {
                    "type": "text"
                },
                "language": {
                    "type": "text"
                },
                "firstName": {
                    "type": "text"
                },
                "lastName": {
                    "type": "text"
                },
                "middleName": {
                    "type": "text"
                },
                "fullName": {
                    "type": "text"
                }
            }
        }
    }
}

```

Then I have define a processor in the pipeline as suggested:  
localhost:9200/\_ingest/pipeline/fullName

```auto
{
    "processors": [
        {
            "set": {
                "field": "fullName",
                "value": "{{firstName}}, {{lastName}}"
            }
        }
    ]
}

```

after ingesting some data using the POST endpoint, when I query for search all records, still there is a **null** value for the **fullName field** in the response. Is there something wrong with my approach.

---

<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 20, 2020, 1:12pm UTC](https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494/4 "2020-05-20T13:12:18Z")

</div>

Could you provide a full recreation script as I did and 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.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<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:** [June 17, 2020, 1:12pm UTC](https://discuss.elastic.co/t/use-copy-to-with-different-delimiters-i-e-etc/233494/5 "2020-06-17T13:12:26Z")

</div>

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