Term filter maching on nested property if top level field is missing

We have a json structure that may have a deleted in several places. With no
explicit mapping, if I post this:

POST /test/fooo/1
{
"properties":{
"deleted":true
}
}

and then query for

GET /test/fooo/_search
{
"query": {
"term": {
"deleted": {
"value": true
}
}
}
}

I get an unexpected match. Basically there is no top level deleted field
(which is what I'm querying for) but there is a properties.deleted field
and the term query falls back to that.

If I add another document to the index with a top level deleted field, it
starts behaving as expected. I guess once the field is in the mapping, it
works as expected.

Is there a way to disable this opportunistic form of matching fields in the
mapping? I'd rather have it fail with an error that the field is missing in
the mapping (which is the fix I guess) than silently fallback to another
field. I still like to use dynamic mappings (i.e. I don't want to disable
that).

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f8d7ed3d-b053-4ca9-9221-3533cf649506%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.