# Search result field name alias

**URL:** <https://discuss.elastic.co/t/search-result-field-name-alias/151913>\
**Category:** Elasticsearch\
**Created:** [October 10, 2018, 6:20pm UTC](https://discuss.elastic.co/t/search-result-field-name-alias/151913 "2018-10-10T18:20:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimyoo](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jimyoo](https://discuss.elastic.co/u/jimyoo)\
**Post date:** [October 10, 2018, 6:20pm UTC](https://discuss.elastic.co/t/search-result-field-name-alias/151913/1 "2018-10-10T18:20:47Z")

</div>

Hello,

I am looking for a way to have a query that returns the name of field differently. Like SQL's " SELECT column\_name AS alias\_name". Feel like there would be an easier solution but only I can think of is using a script to achieve this. For example,

```
  "script_fields" : {
    "alias_name" : {
      "script" : {
        "source" : "doc['column_name'].value",
        "lang" : "painless"
      }

```

And outcome,

```
 "_source":{
    "column_other1": "value1",
    "column_other2":"value2",
    .....
 },
 "fields":{
    "alias_name":[
      "value"

```

Is there a better solution than this? I concern performance using the script.  
Thanks in advance,

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [October 11, 2018, 9:58am UTC](https://discuss.elastic.co/t/search-result-field-name-alias/151913/2 "2018-10-11T09:58:16Z")

</div>

Hi @jimyoo,  
Maybe field aliases? [https://www.elastic.co/guide/en/elasticsearch/reference/6.4/alias.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/alias.html)

---

<div class="post-metadata">

**Author:** ![jimyoo](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jimyoo](https://discuss.elastic.co/u/jimyoo)\
**Post date:** [October 11, 2018, 7:01pm UTC](https://discuss.elastic.co/t/search-result-field-name-alias/151913/3 "2018-10-11T19:01:07Z")

</div>

Thanks Andrei for the information.

That seems a good solution for mapping statically. However, I wonder, instead, if we can do dynamically at the search time only.  
Also even with "Alias datatype", alias names are not present in the document source I can't think of how that (alias) name can be shown in the search results. i.e., in "fields" or "\_source".

---

<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 8, 2018, 7:01pm UTC](https://discuss.elastic.co/t/search-result-field-name-alias/151913/4 "2018-11-08T19:01:11Z")

</div>

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