# How to group or merge multiple fields to one field name

**URL:** <https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985>\
**Category:** Kibana\
**Created:** [March 22, 2024, 11:56am UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985 "2024-03-22T11:56:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aton/32/132869_2.png) [@Aton](https://discuss.elastic.co/u/Aton)\
**Post date:** [March 22, 2024, 11:56am UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/1 "2024-03-22T11:56:04Z")

</div>

hi,  
I have a problem, I have several fields with similar names, for example: rest.direction, mmu.direction, xml.direction, and I need them to be displayed in Kiban only under one field, for example "direction". Is it possible to do it?? what I read, the alias is only for one field.

---

<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:** [March 22, 2024, 12:36pm UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/2 "2024-03-22T12:36:29Z")

</div>

Welcome!

Have a look at field aliases.

> **[Alias field type | Elasticsearch Guide \[8.12\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/field-alias.html)**

---

<div class="post-metadata">

**Author:** ![Aton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aton/32/132869_2.png) [@Aton](https://discuss.elastic.co/u/Aton)\
**Post date:** [March 22, 2024, 2:23pm UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/3 "2024-03-22T14:23:58Z")

</div>

Thanks for the answer, but I don't know if alias is the right solution. I guess I can't set it up, I called it like this and the source for the alias always changes, a new one is not added.

```auto
PUT index_name/_mapping
{
  "properties": {
    "direction": {
      "type": "alias",
      "path": "rest.direction" 
    }
  }
}
 
PUT index_name/_mapping
{
  "properties": {
    "direction": {
      "type": "alias",
      "path": "xml.direction" 
    }
  }
} 

```

---

<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:** [March 22, 2024, 2:52pm UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/4 "2024-03-22T14:52:52Z")

</div>

Not sure I understand what you're saying. A complete example would help.

But anyway, the other option could be runtime fields.

---

<div class="post-metadata">

**Author:** ![Aton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aton/32/132869_2.png) [@Aton](https://discuss.elastic.co/u/Aton)\
**Post date:** [March 22, 2024, 3:10pm UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/5 "2024-03-22T15:10:31Z")

</div>

I need make

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/4/b4eef0f3d5001b2336e895730d19066123a971f6.png)

---

<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:** [March 22, 2024, 4:02pm UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/6 "2024-03-22T16:02:19Z")

</div>

So field alias should work.  
Runtime fields as well. But I prefer the former in that case.

---

<div class="post-metadata">

**Author:** ![Aton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aton/32/132869_2.png) [@Aton](https://discuss.elastic.co/u/Aton)\
**Post date:** [March 25, 2024, 10:11am UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/7 "2024-03-25T10:11:06Z")

</div>

I don know writt this alliases for one name "direction" for more source fields. my source path is always overwritten Plese send me example.

---

<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:** [March 25, 2024, 10:31am UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/8 "2024-03-25T10:31:40Z")

</div>

```auto
DELETE /test1,test2
PUT /test1
{
  "mappings": {
    "properties": {
      "xml.direction": {
        "type": "text"
      },
      "direction": {
        "type": "alias",
        "path": "xml.direction" 
      }
    }
  }
}
PUT /test2
{
  "mappings": {
    "properties": {
      "rest.direction": {
        "type": "text"
      },
      "direction": {
        "type": "alias",
        "path": "rest.direction" 
      }
    }
  }
}

POST /test1/_doc
{
  "xml.direction": "foo"
}
POST /test2/_doc
{
  "rest.direction": "bar"
}

GET /test1,test2/_search
{
  "query": {
    "match": {
      "direction": "foo bar"
    }
  }
}

```

Then in Kibana:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/3/c3b3b304c6f3b9f57065e2b96ad127148560737b.png)

---

<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:** [April 22, 2024, 10:32am UTC](https://discuss.elastic.co/t/how-to-group-or-merge-multiple-fields-to-one-field-name/355985/9 "2024-04-22T10:32:19Z")

</div>

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