Q: How to get distinct keys of a nested object in an elasticsearch document? I'd like to look across an index for a unique list of keys in a nested object. 
So in the example below, I want the output 
["alpha", "beta", "gamma", "sigma", "theta" ]

Much of the google search results were around unique values instead of the keys.
Example docs: 
{
    "foo": "bar",
    "fooNested": {
        "alpha": 1,
        "beta": 4,
        "gamma": 2,
     }
},
{
    "foo": "HelloWorld",
    "fooNested": {
        "sigma": 9,
        "theta": 1
     }
}

Is this possible using the rest api?

A: You can use mapping api to get all properties in index and parse it client side to list properties under nested object or you can store fields as values and query it.
example.
"fooNested": {
        "sigma": 9,
        "theta": 1,
        "keys":["sigma","theta"]
     }

