# Java Boolean Match Query

**URL:** <https://discuss.elastic.co/t/java-boolean-match-query/11630>\
**Category:** Elasticsearch\
**Created:** [April 18, 2013, 12:08pm UTC](https://discuss.elastic.co/t/java-boolean-match-query/11630 "2013-04-18T12:08:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat\_3](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@Pat\_3](https://discuss.elastic.co/u/Pat_3)\
**Post date:** [April 18, 2013, 12:08pm UTC](https://discuss.elastic.co/t/java-boolean-match-query/11630/1 "2013-04-18T12:08:22Z")

</div>

Hi,

how do I specify a boolean match query in Java? E.g. something like

{  
"match" : {  
"message" : {  
"query" : "this is a test",  
"operator" : "and"  
}  
}  
}

I tried something like

QueryBuilders.matchQuery( elasticsearchField, searchStrings ).operator( MatchQueryBuilder.Operator.AND )

where searchStrings is a List of Strings, but this doesn't return any  
results.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 19, 2013, 7:12am UTC](https://discuss.elastic.co/t/java-boolean-match-query/11630/2 "2013-04-19T07:12:08Z")

</div>

Hey,

have you tried making it a string like "this is a test" and not a list of  
strings? In case that is not working, can you provide a gist with a sample?

--Alex

On Thu, Apr 18, 2013 at 2:08 PM, Pat [elasticsearch@hushmail.com](mailto:elasticsearch@hushmail.com) wrote:

> Hi,
> 
> how do I specify a boolean match query in Java? E.g. something like
> 
> {  
> "match" : {  
> "message" : {  
> "query" : "this is a test",  
> "operator" : "and"  
> }  
> }  
> }
> 
> I tried something like
> 
> QueryBuilders.matchQuery( elasticsearchField, searchStrings ).operator( MatchQueryBuilder.Operator.AND )
> 
> where searchStrings is a List of Strings, but this doesn't return any  
> results.
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Pat\_3](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@Pat\_3](https://discuss.elastic.co/u/Pat_3)\
**Post date:** [April 19, 2013, 8:28am UTC](https://discuss.elastic.co/t/java-boolean-match-query/11630/3 "2013-04-19T08:28:35Z")

</div>

This works, thanks! Neither String nor a List seems to work,  
though.

Am Freitag, 19. April 2013 09:12:08 UTC+2 schrieb Alexander Reelsen:

> Hey,
> 
> have you tried making it a string like "this is a test" and not a list of  
> strings? In case that is not working, can you provide a gist with a sample?
> 
> --Alex
> 
> On Thu, Apr 18, 2013 at 2:08 PM, Pat \<[elasti...@hushmail.com](mailto:elasti...@hushmail.com) \<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > how do I specify a boolean match query in Java? E.g. something like
> > 
> > {  
> > "match" : {
> > 
> > ```
> > "message" : {
> > "query" : "this is a test",
> > 
> > "operator" : "and"
> > }
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > I tried something like
> > 
> > QueryBuilders.matchQuery( elasticsearchField, searchStrings ).operator( MatchQueryBuilder.Operator.AND )
> > 
> > where searchStrings is a List of Strings, but this doesn't return any  
> > results.
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
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, 2:40am UTC](https://discuss.elastic.co/t/java-boolean-match-query/11630/4 "2017-07-06T02:40:29Z")

</div>


