Search result field name alias



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,

    "column_other1": "value1",

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

(Andrei Stefan) #2

Hi @jimyoo,
Maybe field aliases?


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".

(system) #4

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