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

**URL:** <https://discuss.elastic.co/t/term-filter-maching-on-nested-property-if-top-level-field-is-missing/19917>\
**Category:** Elasticsearch\
**Created:** [September 22, 2014, 3:44pm UTC](https://discuss.elastic.co/t/term-filter-maching-on-nested-property-if-top-level-field-is-missing/19917 "2014-09-22T15:44:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jilles\_van\_Gurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jilles_van_gurp/32/879_2.png) [@Jilles\_van\_Gurp](https://discuss.elastic.co/u/Jilles_van_Gurp)\
**Post date:** [September 22, 2014, 3:44pm UTC](https://discuss.elastic.co/t/term-filter-maching-on-nested-property-if-top-level-field-is-missing/19917/1 "2014-09-22T15:44:53Z")

</div>

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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/f8d7ed3d-b053-4ca9-9221-3533cf649506%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:00am UTC](https://discuss.elastic.co/t/term-filter-maching-on-nested-property-if-top-level-field-is-missing/19917/2 "2017-07-06T01:00:37Z")

</div>

Closed on July 6, 2017, 1:00am UTC


