# Alias Datatype with multi-fields value

**URL:** <https://discuss.elastic.co/t/alias-datatype-with-multi-fields-value/203028>\
**Category:** Elasticsearch\
**Created:** [October 10, 2019, 1:00pm UTC](https://discuss.elastic.co/t/alias-datatype-with-multi-fields-value/203028 "2019-10-10T13:00:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [October 10, 2019, 1:00pm UTC](https://discuss.elastic.co/t/alias-datatype-with-multi-fields-value/203028/1 "2019-10-10T13:00:30Z")

</div>

Hi All,

I am trying to creating a mapping with aliases that involve mapping to a multifield property. However, I am running into errors. I have read the docs on the alias datatype, however I don't think it is clear enough to determine whether what I am trying to do is allowed.

Below is a snippet of what I am trying to do.

```auto
    "properties": {
      "userId": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        }
      },
      "deviceUsername": {
        "type": "alias",
        "path": "userId",
        "fields": {
          "keyword": {
            "type": "alias",
            "path": "userId.keyword"
          }
        }
      }
    }

```

This results in the following error:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [deviceUsername] has unsupported parameters: [fields : {keyword={path=userId.keyword, type=alias}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Mapping definition for [deviceUsername] has unsupported parameters: [fields : {keyword={path=userId.keyword, type=alias}}]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Mapping definition for [deviceUsername] has unsupported parameters: [fields : {keyword={path=userId.keyword, type=alias}}]"
    }
  },
  "status": 400
}

```

I have also tried the following:

```auto
    "properties": {
      "userId": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        }
      },
      "deviceUsername": {
        "type": "alias",
        "path": "userId"
      },
      "deviceUsername.keyword": {
        "type": "alias",
        "path": "userId.keyword"
      }
    }

```

This results in the error:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Cannot merge a field alias mapping [deviceUsername] with a mapping that is not for a field alias."
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Cannot merge a field alias mapping [deviceUsername] with a mapping that is not for a field alias.",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "Cannot merge a field alias mapping [deviceUsername] with a mapping that is not for a field alias."
    }
  },
  "status": 400
}

```

Is there a way to achieve what I am trying to do, or is this not possible?

---

<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:** [November 7, 2019, 1:00pm UTC](https://discuss.elastic.co/t/alias-datatype-with-multi-fields-value/203028/2 "2019-11-07T13:00:41Z")

</div>

Closed on November 7, 2019, 1:00pm UTC

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