Excluding object/nested data in search


(Bent Coder) #1

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"
        }
      ]
    },
    ....
  },

(Bent Coder) #2

Solution:

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

(system) #3

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