# Java API Query for \_all field in match:

**URL:** https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745
**Category:** Elasticsearch
**Created:** [June 4, 2015, 7:32am UTC](https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745 "2015-06-04T07:32:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)
#### Post date: [June 4, 2015, 7:32am UTC](https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745/1 "2015-06-04T07:32:54Z")

</div>

Hi,

Am using a query :

GET ymme/ymmetype/\_search  
{  
"size": 20,  
"query": {  
"match": {  
"\_all":  
{  
"query": "2000/sun ",  
"operator": "and"  
}  
}  
}  
}

I would like to use the relevant query using Java API using query builders,

Can anyone post the Java API code to the above query....

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/e85e326f-efb9-4965-8498-6c6d48c3a44d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e85e326f-efb9-4965-8498-6c6d48c3a44d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)
#### Post date: [June 4, 2015, 9:07am UTC](https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745/2 "2015-06-04T09:07:28Z")

</div>

query =  
filteredQuery(QueryBuilders.queryString("2000/sun").defaultOperator("and"),  
null);

response =  
client.prepareSearch(yemme).setTypes(ymmetype).setQuery(query).setSize(20).execute().actionGet();

in query string, you might want to escape the slash as it means something  
like the regex usage.

es has moved to [https://discuss.elastic.co/](https://discuss.elastic.co/) , you should post your question  
there.

hth

jason

On Thursday, June 4, 2015 at 3:32:54 PM UTC+8, Muddadi Hemaanusha wrote:

> Hi,
> 
> Am using a query :
> 
> GET ymme/ymmetype/\_search  
> {  
> "size": 20,  
> "query": {  
> "match": {  
> "\_all":  
> {  
> "query": "2000/sun ",  
> "operator": "and"  
> }  
> }  
> }  
> }
> 
> I would like to use the relevant query using Java API using query builders,
> 
> Can anyone post the Java API code to the above query....

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/ab1431c1-0fe9-4fa2-b57b-c1ee9a414042%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ab1431c1-0fe9-4fa2-b57b-c1ee9a414042%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)
#### Post date: [June 4, 2015, 9:58am UTC](https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745/3 "2015-06-04T09:58:38Z")

</div>

Hi Jason,

Thanks for your response , but I would like to build the query using  
matchQuery and I have done even settings with different analyzers and  
filters, I got the relevant query of Java API.

BoolQueryBuilder builder= boolQuery();  
builder.must(QueryBuilders.matchQuery("\_all",  
term).operator(MatchQueryBuilder.Operator.AND));

Thank You..

On Thursday, June 4, 2015 at 2:37:28 PM UTC+5:30, Jason Wee wrote:

> query =  
> filteredQuery(QueryBuilders.queryString("2000/sun").defaultOperator("and"),  
> null);
> 
> response =  
> client.prepareSearch(yemme).setTypes(ymmetype).setQuery(query).setSize(20).execute().actionGet();
> 
> in query string, you might want to escape the slash as it means something  
> like the regex usage.
> 
> es has moved to [https://discuss.elastic.co/](https://discuss.elastic.co/) , you should post your  
> question there.
> 
> hth
> 
> jason
> 
> On Thursday, June 4, 2015 at 3:32:54 PM UTC+8, Muddadi Hemaanusha wrote:
> 
> > Hi,
> > 
> > Am using a query :
> > 
> > GET ymme/ymmetype/\_search  
> > {  
> > "size": 20,  
> > "query": {  
> > "match": {  
> > "\_all":  
> > {  
> > "query": "2000/sun ",  
> > "operator": "and"  
> > }  
> > }  
> > }  
> > }
> > 
> > I would like to use the relevant query using Java API using query  
> > builders,
> > 
> > Can anyone post the Java API code to the above query....

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/a886c363-15f1-4a9e-adc1-9975ef8f2078%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a886c363-15f1-4a9e-adc1-9975ef8f2078%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Pushpak\_R\_Chavan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pushpak_r_chavan/32/15569_2.png) [@Pushpak\_R\_Chavan](https://discuss.elastic.co/u/Pushpak_R_Chavan)
#### Post date: [February 16, 2017, 10:15am UTC](https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745/4 "2017-02-16T10:15:22Z")

</div>

Hi ,

I am using elastic search 5.1.2 , I have the query like as below.

GET /suggestor/\_search  
{  
"size": 10,  
"query": {  
"match": {  
"\_all": {  
"query": "ri",  
"operator": "and"  
}  
}  
}  
}

Can you please let me know how to fetch results using java api.

---

<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 5, 2017, 10:03pm UTC](https://discuss.elastic.co/t/java-api-query-for--all-field-in-match/23745/5 "2017-07-05T22:03:09Z")

</div>


