Source exclude wrong when field is empty

Hy, I'm trying to exclude one field from my data and is working wrong on ES 6

Query

GET /warehouses/doc/_search
{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      }
    }
  },
  "_source": {
    "excludes": [
      "user.active"
    ]
  }
}

Excluding field "active" from user with data like this is working perfectly:

{
    "active": true,
    "warehouse": "London",
    "user": ["active":true,"name":"Mike"]
}

RESULT

{
    "active": true,
    "warehouse": "London",
    "user": ["name":"Mike"]
}

When user is empty, ES 6 dont work well, removes it:

{
    "active": true,
    "warehouse": "London",
    "user": []
}

RESULT

{
    "active": true,
    "warehouse": "London"
}

I don’t think there is a way to prevent that.

@dadoonet, on ES 5 it works well.

Oh?

I think @tanguy might know.

Thx @dadoonet

@tanguy, can you follow this post and tell me something, please.

POST /test/doc/0
{
"active": true,
"warehouse": "London",
"user": ["active":true,"name":"Mike"]
}

is not a valid JSON content and fails on 5.4, 5.6 and 6.0.

Are you using nested documents? If so can you please post the mapping you are using?

@tanguy, use this data:

POST /test/doc/0
{
  "active": true,
  "warehouse": "London",
  "user": [
    {
      "active": true,
      "name": "Mike"
    },
    {
      "active": true,
      "name": "Jimmy"
    }
  ]
}

POST /test/doc/1
{
  "active": true,
  "warehouse": "London",
  "user": []
}

GET /test/doc/_search
{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      }
    }
  },
  "_source": {
    "excludes": [
      "user.active"
    ]
  }
}

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