Create an Index on Nested Keys in Collection

I want to create a index for the following collection which will index distict keys under contexts.

```[
  {
    "contexts":{
      "contextA": {
        "value": 1
      },
      "contextB": {
        "value": 2
      }
    }
  },
  {
    "contexts": {
      "contextA": {
        "value": 3
      },
      "contextB": {
        "value": 4
      },
      "contextC": {
        "value": 4
      }
    }
  }
]
`

in this case the above example would contain a index with the following

[
"contextA",
"contextB",
"contextC"
]

Is there a possible way to achive this ?