# Different null\_value for different doc type of same index

**URL:** <https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673>\
**Category:** Elasticsearch\
**Created:** [August 10, 2017, 9:18pm UTC](https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673 "2017-08-10T21:18:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gchen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gchen](https://discuss.elastic.co/u/gchen)\
**Post date:** [August 10, 2017, 9:18pm UTC](https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673/1 "2017-08-10T21:18:07Z")

</div>

Hi

Is it possible to set the null\_value to different values for different doc type of same index?

I'm able to do it for version 1.4. I'm working on upgrading our cluster to 2.4 now and its erroring out.

```javascript
{
  "text "status": 400,
   "error": {
    "caused_by": {
      "reason": "Mapper for [product] conflicts with existing mapping in other types:\n[mapper [product] is used by multiple types. Set update_all_types to true to update [null_value] across all types.]",
      "type": "illegal_argument_exception"
    },
    "reason": "Failed to parse mapping [my_doc_type]: Mapper for [product] conflicts with existing mapping in other types:\n[mapper [product] is used by multiple types. Set update_all_types to true to update [null_value] across all types.]",
    "type": "mapper_parsing_exception",
    "root_cause": [
      {
        "reason": "Failed to parse mapping [my_doc_type]: Mapper for [product] conflicts with existing mapping in other types:\n[mapper [product] is used by multiple types. Set update_all_types to true to update [null_value] across all types.]",
        "type": "mapper_parsing_exception"
      }
    ]
  }
}

```

I want to have something like...

```javascript
{
 "mappings": {
       "type_one": {
            "properties": {
                "product": {
                    "type": "string",
                    "null_value": "type_one_value"
                }
            }
        },
       "type_two": {
            "properties": {
                "product": {
                    "type": "string",
                    "null_value": "type_two_value"
                }
            }
        }
}

```

---

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [August 10, 2017, 11:47pm UTC](https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673/2 "2017-08-10T23:47:29Z")

</div>

Not that I am aware [[1]](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#field-conflicts).

Since types are going away in 6.0 anyways, I would maybe re-think how you are organizing your documents in such a way that this is not a problem. `_type` is just another field. If performance for the affected queries is not of too much concern, you may want to take a look at [scripted fields](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-script-fields.html)

---

<div class="post-metadata">

**Author:** ![gchen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gchen](https://discuss.elastic.co/u/gchen)\
**Post date:** [August 11, 2017, 2:10am UTC](https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673/3 "2017-08-11T02:10:26Z")

</div>

Thanks for the comment. Most likely that's what i'm going to do. But we have a considerable size cluster, about 40TB, so the number of indices that we have to create will be significant.

---

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [August 14, 2017, 9:14pm UTC](https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673/4 "2017-08-14T21:14:14Z")

</div>

one other solution would be to run these index requests with an ingest-pipeline that sets fields when they are null to specific values you wish

---

<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:** [September 11, 2017, 9:14pm UTC](https://discuss.elastic.co/t/different-null-value-for-different-doc-type-of-same-index/96673/5 "2017-09-11T21:14:36Z")

</div>

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