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] https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.3/java-term-level-queries.html

Thank you Mark for your quick reply and pointer!