Excluding object/nested data in search

Hi,

I looked for this but couldn't find an answer. I want to exclude nested/object property of document in my search. So in the case below, when I search for "football" with ID "1", I don't want to see "leagues" property coming back in my result. Is this possible? If so, please either direct me to the documentation or show me an example query.

Much appreciated.

Thanks

  {
    "_index": "football_2018-02-21-101025",
    "_type": "football",
    "_id": "1",
    "_score": null,
    "_source": {
      "id": 1,
      "name": "USA"
      "leagues": [
        {
          "id": 1,
          "name": "Major League Soccer"
        },
        {
          "id": 2,
          "name": "United Soccer League"
        }
      ]
    },
    ....
  },

Solution:

{
  "query": {
    "term" : { "id" : 1 } 
  },
  "_source": {"excludes": [ "*" ]}
}
1 Like

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