# Exists filter on fields with index\_name not getting all documents

**URL:** <https://discuss.elastic.co/t/exists-filter-on-fields-with-index-name-not-getting-all-documents/20085>\
**Category:** Elasticsearch\
**Created:** [October 6, 2014, 8:25am UTC](https://discuss.elastic.co/t/exists-filter-on-fields-with-index-name-not-getting-all-documents/20085 "2014-10-06T08:25:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmat0n](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmat0n/32/1235_2.png) [@rmat0n](https://discuss.elastic.co/u/rmat0n)\
**Post date:** [October 6, 2014, 8:25am UTC](https://discuss.elastic.co/t/exists-filter-on-fields-with-index-name-not-getting-all-documents/20085/1 "2014-10-06T08:25:50Z")

</div>

Hi guys,

How to reproduce: [https://gist.github.com/rmat0n/7b6f4f0398dc5f0966b4](https://gist.github.com/rmat0n/7b6f4f0398dc5f0966b4)

I created 2 mapping with a testtext field on both, the difference is that  
each mapping have a different index\_name for the field: the first mapping  
use 1.testtext and the second mapping use 2.testtext.  
Then putting 1 object on each mapping. Here I have 2 objects with the same  
field test text but on different mappings.

Now I query using the exists filter _(also tested using the exists syntax  
in the query\_string)_ on the field name:

{  
"filter": {  
"exists": {  
"field" : "testtext"  
}  
}  
}

This query only returns the document added to the first mapping and not the document added to the second mapping.  
I expected to get back the 2 objects because both have the testtext field.

Reading the documentation [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-object-type.html#\_path\_3](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-object-type.html#_path_3): _there is an automatic detection from logical full path and into the **index\_name** and vice versa_.  
So, even if I don't query the index\_name, I should be able to get it by the field name _(path)_.  
I could have expected to get both or none but only the first seems weird. Maybe I am missing something.

Thanks in advance.

--  
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/09ea42ae-3d7c-4306-a334-cd5ee4171ad4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/09ea42ae-3d7c-4306-a334-cd5ee4171ad4%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, 12:58am UTC](https://discuss.elastic.co/t/exists-filter-on-fields-with-index-name-not-getting-all-documents/20085/2 "2017-07-06T00:58:09Z")

</div>


