# Field aliases in search results

**URL:** <https://discuss.elastic.co/t/field-aliases-in-search-results/237354>\
**Category:** Elasticsearch\
**Created:** [June 16, 2020, 6:57pm UTC](https://discuss.elastic.co/t/field-aliases-in-search-results/237354 "2020-06-16T18:57:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ram\_Jeghan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_jeghan/32/48128_2.png) [@Ram\_Jeghan](https://discuss.elastic.co/u/Ram_Jeghan)\
**Post date:** [June 16, 2020, 6:57pm UTC](https://discuss.elastic.co/t/field-aliases-in-search-results/237354/1 "2020-06-16T18:57:51Z")

</div>

The field aliases in search results show the original field names and not aliases.

How do we get the alias field names in the search result.

Ex:

```auto
    PUT myindex
    {
      "mappings": {
          "properties": {
            "firstname": {
              "type": "text"
            },
            "fn": {
              "type": "alias",
              "path": "firstname" 
            }
        }
      }
    }

    POST myindex/_doc
    {
      "firstname": "hello"
    }

    GET myindex/_search
    {
      "query": {
        "match": {
          "fn": "hello"
        }
      }
    }

```

In the result we get the below output.

```auto
  {
      "took" : 0,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 1,
          "relation" : "eq"
        },
        "max_score" : 0.6931471,
        "hits" : [
          {
            "_index" : "myindex",
            "_type" : "_doc",
            "_id" : "uxp7vnIBJVpfmbc3lqnD",
            "_score" : 0.6931471,
            "_source" : {
              "firstname" : "hello"
            }
          }
        ]
      }
    }

```

How do we get a result like this:

```auto
  {
      "took" : 0,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 1,
          "relation" : "eq"
        },
        "max_score" : 0.6931471,
        "hits" : [
          {
            "_index" : "myindex",
            "_type" : "_doc",
            "_id" : "uxp7vnIBJVpfmbc3lqnD",
            "_score" : 0.6931471,
            "_source" : {
              "fn" : "hello"
            }
          }
        ]
      }
    }

```

---

<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:** [July 14, 2020, 6:58pm UTC](https://discuss.elastic.co/t/field-aliases-in-search-results/237354/2 "2020-07-14T18:58:01Z")

</div>

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