# Using AND in query string

**URL:** <https://discuss.elastic.co/t/using-and-in-query-string/7915>\
**Category:** Elasticsearch\
**Created:** [May 30, 2012, 5:08pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915 "2012-05-30T17:08:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 5:08pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/1 "2012-05-30T17:08:03Z")

</div>

Is there a easy way to give a "AND" clause in the \_search?q= query string?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 30, 2012, 6:11pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/2 "2012-05-30T18:11:45Z")

</div>

Use something like q=+term1 +term2  
It should work

HTH  
David

Le 30 mai 2012 à 19:08, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :

> Is there a easy way to give a "AND" clause in the \_search?q= query string?et

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 6:25pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/3 "2012-05-30T18:25:53Z")

</div>

On Wed, May 30, 2012 at 11:11 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Use something like q=+term1 +term2  
> It should work
> 
> I tried this. I am pretty sure I am doing something wrong here 🙂

curl -XGET '[http://dslg1:9200/documents/object/\_search?q=+20+EAAgfyaxpzdfcfv9Qexq1WtGvA](http://dslg1:9200/documents/object/_search?q=+20+EAAgfyaxpzdfcfv9Qexq1WtGvA)'

curl: (52) Empty reply from server

My document that I expect to match is something like:

{ "attributes" : [  
{ "base64" : true,  
"encrypted" : true,  
"name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
},  
{ "base64" : false,  
"encrypted" : false,  
"age" : "32"  
}  
],  
"version" : 1337298622093  
}

> HTH  
> David
> 
> Le 30 mai 2012 à 19:08, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> > Is there a easy way to give a "AND" clause in the \_search?q= query  
> > string?et

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 30, 2012, 6:53pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/4 "2012-05-30T18:53:08Z")

</div>

Try to encode URL

Something like %20 instead of space...  
%xx (i don't remember it) instead of plus sign.

David

Le 30 mai 2012 à 20:25, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :

> On Wed, May 30, 2012 at 11:11 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Use something like q=+term1 +term2  
> It should work
> 
> I tried this. I am pretty sure I am doing something wrong here 🙂
> 
> curl -XGET '[http://dslg1:9200/documents/object/\_search?q=+20](http://dslg1:9200/documents/object/_search?q=+20) +EAAgfyaxpzdfcfv9Qexq1WtGvA'
> 
> curl: (52) Empty reply from server
> 
> My document that I expect to match is something like:
> 
> { "attributes" : [  
> { "base64" : true,  
> "encrypted" : true,  
> "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> },  
> { "base64" : false,  
> "encrypted" : false,  
> "age" : "32"  
> }  
> ],  
> "version" : 1337298622093  
> }
> 
> HTH  
> David
> 
> Le 30 mai 2012 à 19:08, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> > Is there a easy way to give a "AND" clause in the \_search?q= query string?et

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 6:58pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/5 "2012-05-30T18:58:03Z")

</div>

Is there a way to explicitly say name:abc AND age:2?

On Wed, May 30, 2012 at 11:53 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Try to encode URL
> 
> Something like %20 instead of space...  
> %xx (i don't remember it) instead of plus sign.
> 
> David
> 
> Le 30 mai 2012 à 20:25, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> On Wed, May 30, 2012 at 11:11 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Use something like q=+term1 +term2  
> > It should work
> > 
> > I tried this. I am pretty sure I am doing something wrong here 🙂
> 
> curl -XGET '[http://dslg1:9200/documents/object/\_search?q=+20+EAAgfyaxpzdfcfv9Qexq1WtGvA](http://dslg1:9200/documents/object/_search?q=+20+EAAgfyaxpzdfcfv9Qexq1WtGvA)'
> 
> curl: (52) Empty reply from server
> 
> My document that I expect to match is something like:
> 
> { "attributes" : [  
> { "base64" : true,  
> "encrypted" : true,  
> "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> },  
> { "base64" : false,  
> "encrypted" : false,  
> "age" : "32"  
> }  
> ],  
> "version" : 1337298622093  
> }
> 
> > HTH  
> > David
> > 
> > Le 30 mai 2012 à 19:08, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> > 
> > > Is there a easy way to give a "AND" clause in the \_search?q= query  
> > > string?et

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 30, 2012, 7:12pm UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/6 "2012-05-30T19:12:03Z")

</div>

I use : +name:abc +age:2

Le 30 mai 2012 à 20:58, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :

> Is there a way to explicitly say name:abc AND age:2?
> 
> On Wed, May 30, 2012 at 11:53 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Try to encode URL
> 
> Something like %20 instead of space...  
> %xx (i don't remember it) instead of plus sign.
> 
> David
> 
> Le 30 mai 2012 à 20:25, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> > On Wed, May 30, 2012 at 11:11 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> > Use something like q=+term1 +term2  
> > It should work
> > 
> > I tried this. I am pretty sure I am doing something wrong here 🙂
> > 
> > curl -XGET '[http://dslg1:9200/documents/object/\_search?q=+20](http://dslg1:9200/documents/object/_search?q=+20) +EAAgfyaxpzdfcfv9Qexq1WtGvA'
> > 
> > curl: (52) Empty reply from server
> > 
> > My document that I expect to match is something like:
> > 
> > { "attributes" : [  
> > { "base64" : true,  
> > "encrypted" : true,  
> > "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> > },  
> > { "base64" : false,  
> > "encrypted" : false,  
> > "age" : "32"  
> > }  
> > ],  
> > "version" : 1337298622093  
> > }
> > 
> > HTH  
> > David
> > 
> > Le 30 mai 2012 à 19:08, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> > 
> > > Is there a easy way to give a "AND" clause in the \_search?q= query string?et

---

<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:26am UTC](https://discuss.elastic.co/t/using-and-in-query-string/7915/7 "2017-07-06T03:26:12Z")

</div>


