It's just a meter of ES interpretation of the two relationships:
- within matches because Elasticsearch allows an object to be within itself.
- contains does NOT match because Elasticsearch treats "contains" as a strict enclosure, requiring the query shape to be strictly inside, not just identical.
I.e.
- Object A is within object B if it is completely enclosed by object B
- Object A contains object B if it encloses it and there is still little extra space in Object A