# Question on bool query for java

**URL:** <https://discuss.elastic.co/t/question-on-bool-query-for-java/8521>\
**Category:** Elasticsearch\
**Created:** [July 26, 2012, 9:37am UTC](https://discuss.elastic.co/t/question-on-bool-query-for-java/8521 "2012-07-26T09:37:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)\
**Post date:** [July 26, 2012, 9:37am UTC](https://discuss.elastic.co/t/question-on-bool-query-for-java/8521/1 "2012-07-26T09:37:08Z")

</div>

i want to construct a query wherein either a field should be absent in the  
document or if present, then it should not contain any of the given words.  
can someone provide an example of doing so?

i know how to do a filter with similar requirements but getting confused  
with query.

thanks

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 27, 2012, 8:21pm UTC](https://discuss.elastic.co/t/question-on-bool-query-for-java/8521/2 "2012-07-27T20:21:31Z")

</div>

If you already have a filter, you can simply wrap it into a filtered query[http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html).  
If your query still doesn't work, post it here and we will try to fix it.

On Thursday, July 26, 2012 5:37:08 AM UTC-4, T Vinod Gupta wrote:

> i want to construct a query wherein either a field should be absent in the  
> document or if present, then it should not contain any of the given words.  
> can someone provide an example of doing so?
> 
> i know how to do a filter with similar requirements but getting confused  
> with query.
> 
> thanks

---

<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, 3:18am UTC](https://discuss.elastic.co/t/question-on-bool-query-for-java/8521/3 "2017-07-06T03:18:44Z")

</div>


