Unexpected exists behaviour on field which value is an array of nested objects

Hello everyone,

The behaviour of the exists query in the following example puzzles me:

PUT i
{
  "mappings": {
    "t": {
      "properties": {
        "foo": {
          "type": "nested",
          "properties": {
            "bar": {
              "type": "long"
            }
          }
        }
      }
    }
  }
}

PUT i/t/1
{
  "foo": [
    {
      "bar": 1
    }
  ]
}

POST i/_refresh

GET i/t/_search
{
  "query": {
    "exists": {
      "field": "foo"
    }
  }
}

The search returns 0 results, while I expected it to return document i/t/1.

Is it the expected behaviour?
If so, I'd appreciate a pointer to the documentation explaining why this is the case.

Thanks in advance,

Alexis F.

N.B.: I ran this example on Elasticsearch 2.3.3.

Yes.

From [1] - " the term-level queries operate on the exact terms that are stored in the inverted index."

"foo" does not exist as an indexed (and therefore searchable) primitive term. It is essentially exists only as a naming prefix for the leaf-level primitive field "foo.bar".

[1] Term level queries | Java API [2.3] | Elastic

Thank you Mark for your quick reply and pointer!