# How to avoid duplicate fields copied during bulk indexing?

**URL:** <https://discuss.elastic.co/t/how-to-avoid-duplicate-fields-copied-during-bulk-indexing/219528>\
**Category:** Elasticsearch\
**Created:** [February 16, 2020, 4:55pm UTC](https://discuss.elastic.co/t/how-to-avoid-duplicate-fields-copied-during-bulk-indexing/219528 "2020-02-16T16:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasad98](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prasad98/32/64837_2.png) [@prasad98](https://discuss.elastic.co/u/prasad98)\
**Post date:** [February 16, 2020, 4:55pm UTC](https://discuss.elastic.co/t/how-to-avoid-duplicate-fields-copied-during-bulk-indexing/219528/1 "2020-02-16T16:55:40Z")

</div>

Hi, I'm trying to create my mappings have multiple types within the same index.

This is how it looks:

```
mappings := map[string]interface{}{
	"properties": map[string]interface{}{
		"category": map[string]interface{}{
			"properties": map[string]interface{}{
				"id": map[string]interface{}{"type": "long"},
				"name": map[string]interface{}{"type": "text"},
				"type": map[string]interface{}{"type": "text"},
				"image_version": map[string]interface{}{
					"type": "nested",
					"properties": map[string]interface{}{
						"image_height": map[string]interface{}{"type": "float"},
						"image_width": map[string]interface{}{"type": "float"},
					},
				},
			},
		},
	},
}

```

This is written in Golang. Consider for assume we've mappings for `promotion` type too.

When I try to bulk index the data, it creates mappings like this:

```
{
  "mappings": {
    "properties": { 
      "category": {
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "keyword"
          },
          "type": {
            "type": "text"
          },
          "image_version": {
            "type": "nested",
            "properties": {
              "image_height": {
                "type": "float"
              },
              "image_width": {
                "type": "float"
              }
            }
          }
        }
      },
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "keyword"
      },
      "type": {
        "type": "text"
      },
      "image_version": {
        "type": "nested",
        "properties": {
          "image_height": {
            "type": "float"
          },
          "image_width": {
            "type": "float"
          }
        }
      },
      "promotions": {
        "properties": {
          "activity_name": {
            "type": "text"
          },
          "app_type": {
            "type": "text"
          }
        }
      }
    }
  }
}

```

As you can notice it is copying `category` fields outside `category` root field too.

Why the fields inside `properties` are being copied outside `category` too? How should I avoid it?

It would be great if anyone can help me with a proper solution. Thank you!

---

<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:** [February 16, 2020, 5:46pm UTC](https://discuss.elastic.co/t/how-to-avoid-duplicate-fields-copied-during-bulk-indexing/219528/2 "2020-02-16T17:46:59Z")

</div>

Let's keep the discussion only in [How to use custom field type in mappings to achieve multiple type mappings within an index?](https://discuss.elastic.co/t/how-to-use-custom-field-type-in-mappings-to-achieve-multiple-type-mappings-within-an-index/219530) as this is basically the same topic.

I'm closing this thread.

---

<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:** [February 16, 2020, 5:47pm UTC](https://discuss.elastic.co/t/how-to-avoid-duplicate-fields-copied-during-bulk-indexing/219528/3 "2020-02-16T17:47:05Z")

</div>


