Workaround for nested objects

You should be able to do this if you set your mapping type to clubs as nested. Then you can use a nested query.

Here is how I'm updating the mapping (before I index data, mappings can't be adjusted afterwards):

PUT soccerplayers
{
  "mappings": {
    "data": {
      "properties": {
        "clubs": {
          "type": "nested" 
        }
      }
    }
  }
}

Then I can use some special syntax to create a filter to give me the right data (I edit the Query DSL, I'm not sure how to do this in the query bar - @Bargs - would Kuery be able to handle nested queries like this?) :

{
  "query": {
    "nested": {
      "path": "clubs",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "clubs.clubName": "Bayern"
              }
            },
            {
              "match": {
                "clubs.status": "active"
              }
            }
          ]
        }
      }
    }
  }
}

Then I get back results where players are only active in Bayern, not Manchester United:

I am seeing an error, though it doesn't seem to affect the actual results:


(@bargs - any idea on that error?)