How to get all Field names with filter(or query) criteria on ElasticSearch?

PUT /test-product
{
  "mappings": {
    "properties": {
      "profile": {
        "type": "nested"
      },
      "product": {
        "type": "nested"
      }
    }
  }
}

i have a index that name's 'test-product'

POST /test-product/_bulk
{ "index" : { "_id" : "1" } }
{ "user":"1", "profile":{"name":"AA", "age": "11", "height": "30"}, "product": {"price": "333", "name": "test", "weight": "10"} }
{ "index" : { "_id" : "2" } }
{ "user":"2", "profile":{"name":"BB", "age": "20"}, "product": {"name": "test"}}

and that index have some docs

I want to get the results as below....

Case 1. when i search for user: 1

profile.name, profile.age, profile.height, product.price, product.name, product.weight

Case 2. when i search for user: 2

profile.name, profile.age, product.name

Is there a way?

elasticsearch will return all the data which are indexed. so you have to index those fields that you want from query

Okay, i guess so.

It would look like this if i created an index.

user | keyName
1 | profile.name
1 | profile.age
1 | profile.height
1 | product.price
1 | product.name
1 | product.weight
2 | profile.name
2 | profile.age
2 | product.name

I'll have to look for another data source..

thanks