# How to use 'exists' filter on no indexed objects/fields

**URL:** <https://discuss.elastic.co/t/how-to-use-exists-filter-on-no-indexed-objects-fields/16112>\
**Category:** Elasticsearch\
**Created:** [March 3, 2014, 4:21pm UTC](https://discuss.elastic.co/t/how-to-use-exists-filter-on-no-indexed-objects-fields/16112 "2014-03-03T16:21:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Han\_JU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han_ju/32/962_2.png) [@Han\_JU](https://discuss.elastic.co/u/Han_JU)\
**Post date:** [March 3, 2014, 4:21pm UTC](https://discuss.elastic.co/t/how-to-use-exists-filter-on-no-indexed-objects-fields/16112/1 "2014-03-03T16:21:42Z")

</div>

Hi, I have some object type like:

{  
'person': {  
'properties': {  
'age': {'index': 'no', 'type': 'long'},  
'name': {'index': 'no', 'type': 'string'}  
}  
}  
}

So in fact these fields are not indexed at all, they are not visible to  
filters. But what I want to is to be able to use 'exists' and 'missing'  
filters on these fields ('person', 'person.age' or 'person.name').  
A simple hack is to add an indexed, boolean field for each no index field,  
like:

{  
'person': {  
'properties': {  
'age': {'index': 'no', 'type': 'long'},  
'age\_exists': {'type': 'boolean'},

```
      'name': {'index': 'no', 'type': 'string'}
      'name_exists': {'index': 'no', 'type': 'boolean'}
   }
 }

```

}

And modify my queries that check field existence on these boolean flag  
fields.  
This works for a few fields like this but now I have plenty of them and it  
also complicates my query logic. So dear elasticsearch users, is there a  
better solution to this?

Thanks.

--  
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/67cc1526-f4a8-4c0b-aaff-a78cf23fca6c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/67cc1526-f4a8-4c0b-aaff-a78cf23fca6c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 3, 2014, 8:43pm UTC](https://discuss.elastic.co/t/how-to-use-exists-filter-on-no-indexed-objects-fields/16112/2 "2014-03-03T20:43:59Z")

</div>

Other than indexing the field, I can't think of another way.

--  
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/cb704734-70ad-4e8b-8595-c3d1e66e7bce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cb704734-70ad-4e8b-8595-c3d1e66e7bce%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Han\_JU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han_ju/32/962_2.png) [@Han\_JU](https://discuss.elastic.co/u/Han_JU)\
**Post date:** [March 3, 2014, 8:53pm UTC](https://discuss.elastic.co/t/how-to-use-exists-filter-on-no-indexed-objects-fields/16112/3 "2014-03-03T20:53:54Z")

</div>

Thanks Binh.

In fact the fields I'm working on are large lists and their only role in  
the query part is `exists`.  
Since they are large number lists, my intuition tells me that it's not a  
very good idea to include in the index. Am I correct?

在 2014年3月3日星期一UTC+1下午9时43分59秒，Binh Ly写道：

> Other than indexing the field, I can't think of another way.

--  
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/52e9b9e3-0693-418e-adf5-4294c9698d11%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/52e9b9e3-0693-418e-adf5-4294c9698d11%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:46am UTC](https://discuss.elastic.co/t/how-to-use-exists-filter-on-no-indexed-objects-fields/16112/4 "2017-07-06T01:46:03Z")

</div>


