# BooleanQuery returning error

**URL:** <https://discuss.elastic.co/t/booleanquery-returning-error/7917>\
**Category:** Elasticsearch\
**Created:** [May 30, 2012, 5:57pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917 "2012-05-30T17:57:09Z")\
**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:57pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917/1 "2012-05-30T17:57:09Z")

</div>

I am getting this error when I try bool query. Did I miss something?

# curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{

```
"bool" : {
    "must" : {
        "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }
    },
    "should" : [
        {
            "term" : { "age" : "20" }
        }
    ],
    "minimum_number_should_match" : 1,
    "boost" : 1.0
}

```

}'

{"error":"SearchPhaseExecutionException[Failed to execute phase [query],  
total failure; shardFailures {[mRAEhEG6QHKNKPEeS0DAWg][documents][1]:  
SearchParseException[[documents][1]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{\n "bool" : {\n "must" :  
{\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
}\n },\n "should" : [\n {\n  
"term" : { "age" : "20" }\n }\n ],\n  
"minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]];  
nested: SearchParseException[[documents][1]: from[-1],size[-1]: Parse  
Failure [No parser for element [bool]]];  
}{[mkOicZNhSga8omWsigTWuw][documents][0]:  
RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse  
Failure [Failed to parse source [{\n "bool" : {\n "must" :  
{\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
}\n },\n "should" : [\n {\n  
"term" : { "age" : "20" }\n }\n ],\n  
"minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]];  
nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse  
Failure [No parser for element [bool]]];  
}{[mRAEhEG6QHKNKPEeS0DAWg][documents][2]:  
SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{\n "bool" : {\n "must" :  
{\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
}\n },\n "should" : [\n {\n  
"term" : { "age" : "20" }\n }\n ],\n  
"minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]];  
nested: SearchParseException[[documents][2]: from[-1],size[-1]: Parse  
Failure [No parser for element [bool]]];  
}{[mkOicZNhSga8omWsigTWuw][documents][4]:  
RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse  
Failure [Failed to parse source [{\n "bool" : {\n "must" :  
{\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
}\n },\n "should" : [\n {\n  
"term" : { "age" : "20" }\n }\n ],\n  
"minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]];  
nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse  
Failure [No parser for element [bool]]];  
}{[mkOicZNhSga8omWsigTWuw][documents][3]:  
RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse  
Failure [Failed to parse source [{\n "bool" : {\n "must" :  
{\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
}\n },\n "should" : [\n {\n  
"term" : { "age" : "20" }\n }\n ],\n  
"minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]];  
nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse  
Failure [No parser for element [bool]]]; }]","status":500}[root@dslg2 ~]#

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 30, 2012, 6:08pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917/2 "2012-05-30T18:08:34Z")

</div>

On Wed, 2012-05-30 at 10:57 -0700, Mohit Anchlia wrote:

> I am getting this error when I try bool query. Did I miss something?

yes - the bool query should be wrapped in "query": {..... }

> # curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{
> 
> ```
> "bool" : {
> "must" : {
> "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }
> },
> "should" : [
> {
> "term" : { "age" : "20" }
> }
> ],
> "minimum_number_should_match" : 1,
> "boost" : 1.0
> }
> 
> ```
> 
> }'
> 
> {"error":"SearchPhaseExecutionException[Failed to execute phase  
> [query], total failure; shardFailures  
> {[mRAEhEG6QHKNKPEeS0DAWg][documents][1]:  
> SearchParseException[[documents][1]: from[-1],size[-1]: Parse Failure  
> [Failed to parse source [{\n "bool" : {\n "must" : {\n  
> "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n },  
> \n "should" : [\n {\n "term" :  
> { "age" : "20" }\n }\n ],\n  
> "minimum\_number\_should\_match" : 1,\n "boost" : 1.0  
> \n }\n}]]]; nested: SearchParseException[[documents][1]:  
> from[-1],size[-1]: Parse Failure [No parser for element  
> [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][0]:  
> RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "bool" : {\n "must" : {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n },\n "should" : [\n {\n "term" : { "age" : "20" }\n }\n],\n "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }{[mRAEhEG6QHKNKPEeS0DAWg][documents][2]: SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "bool" : {\n "must" : {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n },\n "should" : [\n {\n "term" : { "age" : "20" }\n }\n],\n "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][4]: RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "bool" : {\n "must" : {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n },\n "should" : [\n {\n "term" : { "age" : "20" }\n }\n],\n "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][3]: RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "bool" : {\n "must" : {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n },\n "should" : [\n {\n "term" : { "age" : "20" }\n }\n],\n "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }]","status":500}[root@dslg2 ~]#

---

<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:21pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917/3 "2012-05-30T18:21:55Z")

</div>

Thanks! I added this and it doesn't return error but I am not getting my  
document back that matches the following criteria:

curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{  
"query" : {  
"bool" : {  
"must" : {  
"term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }  
},  
"should" : [  
{  
"term" : { "age" : "20" }  
}  
],  
"minimum\_number\_should\_match" : 1,  
"boost" : 1.0  
}  
}  
}'

My document is:

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

On Wed, May 30, 2012 at 11:08 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Wed, 2012-05-30 at 10:57 -0700, Mohit Anchlia wrote:
> 
> > I am getting this error when I try bool query. Did I miss something?
> 
> yes - the bool query should be wrapped in "query": {..... }
> 
> > # curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{
> > 
> > ```
> > "bool" : {
> > "must" : {
> > "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }
> > },
> > "should" : [
> > {
> > "term" : { "age" : "20" }
> > }
> > ],
> > "minimum_number_should_match" : 1,
> > "boost" : 1.0
> > }
> > 
> > ```
> > 
> > }'
> > 
> > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > [query], total failure; shardFailures  
> > {[mRAEhEG6QHKNKPEeS0DAWg][documents][1]:  
> > SearchParseException[[documents][1]: from[-1],size[-1]: Parse Failure  
> > [Failed to parse source [{\n "bool" : {\n "must" : {\n  
> > "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n },  
> > \n "should" : [\n {\n "term" :  
> > { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0  
> > \n }\n}]]]; nested: SearchParseException[[documents][1]:  
> > from[-1],size[-1]: Parse Failure [No parser for element  
> > [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][0]:  
> > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> > nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse  
> > Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> > {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term"  
> > : { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]];  
> > }{[mRAEhEG6QHKNKPEeS0DAWg][documents][2]:  
> > SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure  
> > [Failed to parse source [{\n "bool" : {\n "must" : {\n  
> > "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term" : {  
> > "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][2]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]];  
> > }{[mkOicZNhSga8omWsigTWuw][documents][4]:  
> > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> > nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse  
> > Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> > {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term"  
> > : { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]];  
> > }{[mkOicZNhSga8omWsigTWuw][documents][3]:  
> > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> > nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse  
> > Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> > {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term"  
> > : { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]]; }]","status":500}[root@dslg2~]#

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 30, 2012, 6:23pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917/4 "2012-05-30T18:23:06Z")

</div>

On Wed, 2012-05-30 at 11:21 -0700, Mohit Anchlia wrote:

> Thanks! I added this and it doesn't return error but I am not getting  
> my document back that matches the following criteria:

I bet your 'name' field is analyzed, but you're using a term query on  
it, which looks for the exact value.

Set the 'name' field to { index: "not\_analyzed"}

clint

> curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{  
> "query" : {  
> "bool" : {  
> "must" : {  
> "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }  
> },  
> "should" : [  
> {  
> "term" : { "age" : "20" }  
> }  
> ],  
> "minimum\_number\_should\_match" : 1,  
> "boost" : 1.0  
> }  
> }  
> }'
> 
> My document is:
> 
> { "attributes" : [  
> { "base64" : true,  
> "encrypted" : true,  
> "ssn" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> },  
> { "base64" : false,  
> "encrypted" : false,  
> "age" : "20"  
> }  
> ],  
> "version" : 1337298622093  
> }
> 
> On Wed, May 30, 2012 at 11:08 AM, Clinton Gormley  
> [clint@traveljury.com](mailto:clint@traveljury.com) wrote:  
> On Wed, 2012-05-30 at 10:57 -0700, Mohit Anchlia wrote:  
> \> I am getting this error when I try bool query. Did I miss  
> something?
> 
> ```
> yes - the bool query should be wrapped in "query": {..... }
> >
> > # curl -XGET 'http://dslg1:9200/documents/object/_search' -d
> '{
> > "bool" : {
> > "must" : {
> > "term" : { "name" :
> "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }
> > },
> > "should" : [
> > {
> > "term" : { "age" : "20" }
> > }
> > ],
> > "minimum_number_should_match" : 1,
> > "boost" : 1.0
> > }
> > }'
> >
> >
> > {"error":"SearchPhaseExecutionException[Failed to execute
> phase
> > [query], total failure; shardFailures
> > {[mRAEhEG6QHKNKPEeS0DAWg][documents][1]:
> > SearchParseException[[documents][1]: from[-1],size[-1]:
> Parse Failure
> > [Failed to parse source [{\n \"bool\" : {\n \"must
> \" : {\n
> > \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==
> \" }\n },
> > \n \"should\" : [\n {\n
> \"term\" :
> > { \"age\" : \"20\" }\n }\n ],\n
> > \"minimum_number_should_match\" : 1,\n \"boost\" :
> 1.0
> > \n }\n}]]]; nested: SearchParseException[[documents][1]:
> > from[-1],size[-1]: Parse Failure [No parser for element
> > [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][0]:
> >
> RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"bool\" : {\n \"must\" : {\n \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==\" }\n },\n \"should\" : [\n {\n \"term\" : { \"age\" : \"20\" }\n }\n],\n \"minimum_number_should_match\" : 1,\n \"boost\" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }{[mRAEhEG6QHKNKPEeS0DAWg][documents][2]: SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"bool\" : {\n \"must\" : {\n \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==\" }\n },\n \"should\" : [\n {\n \"term\" : { \"age\" : \"20\" }\n }\n],\n \"minimum_number_should_match\" : 1,\n \"boost\" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][4]: RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"bool\" : {\n \"must\" : {\n \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==\" }\n },\n \"should\" : [\n {\n \"term\" : { \"age\" : \"20\" }\n }\n],\n \"minimum_number_should_match\" : 1,\n \"boost\" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][3]: RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"bool\" : {\n \"must\" : {\n \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==\" }\n },\n \"should\" : [\n {\n \"term\" : { \"age\" : \"20\" }\n }\n],\n \"minimum_number_should_match\" : 1,\n \"boost\" : 1.0\n }\n}]]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse Failure [No parser for element [bool]]]; }]","status":500}[root@dslg2 ~]#
> >
> 
> ```

---

<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:41pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917/5 "2012-05-30T18:41:04Z")

</div>

This is what I did, but I still get no hits:

curl -XPOST '[http://dslg1:9200/documents3/](http://dslg1:9200/documents3/)' -d '{  
"mappings" : {  
"object" : {  
"properties" : {  
"attributes" : {  
"type" : "nested",  
"name" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}  
}  
}'

query:

curl -XGET '[http://dslg1:9200/documents3/object/\_search](http://dslg1:9200/documents3/object/_search)' -d '{  
"query" : {  
"bool" : {  
"must" : {  
"term" : { "attributes.name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }  
},  
"should" : [  
{  
"term" : { "attributes.age" : "20" }  
}  
],  
"minimum\_number\_should\_match" : 1,  
"boost" : 1.0  
}  
}  
}'

{"took":3,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}

Document that I posted:

{ "attributes" : [  
{ "base64" : true,  
"encrypted" : true,  
"name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
},  
{ "base64" : false,  
"encrypted" : false,  
"age" : "20"  
}  
],  
"version" : 1337298622093  
}  
On Wed, May 30, 2012 at 11:23 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Wed, 2012-05-30 at 11:21 -0700, Mohit Anchlia wrote:
> 
> > Thanks! I added this and it doesn't return error but I am not getting  
> > my document back that matches the following criteria:
> 
> I bet your 'name' field is analyzed, but you're using a term query on  
> it, which looks for the exact value.
> 
> Set the 'name' field to { index: "not\_analyzed"}
> 
> clint
> 
> > curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{  
> > "query" : {  
> > "bool" : {  
> > "must" : {  
> > "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }  
> > },  
> > "should" : [  
> > {  
> > "term" : { "age" : "20" }  
> > }  
> > ],  
> > "minimum\_number\_should\_match" : 1,  
> > "boost" : 1.0  
> > }  
> > }  
> > }'
> > 
> > My document is:
> > 
> > { "attributes" : [  
> > { "base64" : true,  
> > "encrypted" : true,  
> > "ssn" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> > },  
> > { "base64" : false,  
> > "encrypted" : false,  
> > "age" : "20"  
> > }  
> > ],  
> > "version" : 1337298622093  
> > }
> > 
> > On Wed, May 30, 2012 at 11:08 AM, Clinton Gormley  
> > [clint@traveljury.com](mailto:clint@traveljury.com) wrote:  
> > On Wed, 2012-05-30 at 10:57 -0700, Mohit Anchlia wrote:  
> > \> I am getting this error when I try bool query. Did I miss  
> > something?
> > 
> > ```
> > yes - the bool query should be wrapped in "query": {..... }
> > >
> > > # curl -XGET 'http://dslg1:9200/documents/object/_search' -d
> > '{
> > > "bool" : {
> > > "must" : {
> > > "term" : { "name" :
> > "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }
> > > },
> > > "should" : [
> > > {
> > > "term" : { "age" : "20" }
> > > }
> > > ],
> > > "minimum_number_should_match" : 1,
> > > "boost" : 1.0
> > > }
> > > }'
> > >
> > >
> > > {"error":"SearchPhaseExecutionException[Failed to execute
> > phase
> > > [query], total failure; shardFailures
> > > {[mRAEhEG6QHKNKPEeS0DAWg][documents][1]:
> > > SearchParseException[[documents][1]: from[-1],size[-1]:
> > Parse Failure
> > > [Failed to parse source [{\n \"bool\" : {\n \"must
> > \" : {\n
> > > \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==
> > \" }\n },
> > > \n \"should\" : [\n {\n
> > \"term\" :
> > > { \"age\" : \"20\" }\n }\n ],\n
> > > \"minimum_number_should_match\" : 1,\n \"boost\" :
> > 1.0
> > > \n }\n}]]]; nested: SearchParseException[[documents][1]:
> > > from[-1],size[-1]: Parse Failure [No parser for element
> > > [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][0]:
> > >
> > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];
> > 
> > ```
> 
> nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse  
> Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> },\n "should" : [\n {\n "term"  
> : { "age" : "20" }\n }\n ],\n  
> "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> }\n}]]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]:  
> Parse Failure [No parser for element [bool]]];  
> }{[mRAEhEG6QHKNKPEeS0DAWg][documents][2]:  
> SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure  
> [Failed to parse source [{\n "bool" : {\n "must" : {\n  
> "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> },\n "should" : [\n {\n "term" : {  
> "age" : "20" }\n }\n ],\n  
> "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> }\n}]]]; nested: SearchParseException[[documents][2]: from[-1],size[-1]:  
> Parse Failure [No parser for element [bool]]];  
> }{[mkOicZNhSga8omWsigTWuw][documents][4]:  
> RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse  
> Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> },\n "should" : [\n {\n "term"  
> : { "age" : "20" }\n }\n ],\n  
> "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> }\n}]]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]:  
> Parse Failure [No parser for element [bool]]];  
> }{[mkOicZNhSga8omWsigTWuw][documents][3]:  
> RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse  
> Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> },\n "should" : [\n {\n "term"  
> : { "age" : "20" }\n }\n ],\n  
> "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> }\n}]]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]:  
> Parse Failure [No parser for element [bool]]]; }]","status":500}[root@dslg2~]#
> 
> > ```
> > >
> > 
> > ```

---

<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, 7:03pm UTC](https://discuss.elastic.co/t/booleanquery-returning-error/7917/6 "2012-05-30T19:03:51Z")

</div>

I changed my mapping like this and it worked. I used array type:

Thanks for your help!!

curl -XPOST '[http://dslg1:9200/documents3/](http://dslg1:9200/documents3/)' -d '{  
"mappings" : {  
"object" : {  
"properties" : {  
"attributes" : {  
"properties" : {  
"name" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}'

On Wed, May 30, 2012 at 11:41 AM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> This is what I did, but I still get no hits:
> 
> curl -XPOST '[http://dslg1:9200/documents3/](http://dslg1:9200/documents3/)' -d '{  
> "mappings" : {  
> "object" : {  
> "properties" : {  
> "attributes" : {  
> "type" : "nested",  
> "name" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> query:
> 
> curl -XGET '[http://dslg1:9200/documents3/object/\_search](http://dslg1:9200/documents3/object/_search)' -d '{  
> "query" : {  
> "bool" : {  
> "must" : {  
> "term" : { "attributes.name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> }  
> },  
> "should" : [  
> {  
> "term" : { "attributes.age" : "20" }
> 
> ```
> }
> ],
> "minimum_number_should_match" : 1,
> "boost" : 1.0
> }
> 
> ```
> 
> }  
> }'
> 
> {"took":3,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}
> 
> Document that I posted:
> 
> { "attributes" : [  
> { "base64" : true,  
> "encrypted" : true,  
> "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="
> 
> ```
> },
> { "base64" : false,
> "encrypted" : false,
> "age" : "20"
> }
> ],
> 
> ```
> 
> "version" : 1337298622093  
> }
> 
> On Wed, May 30, 2012 at 11:23 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> 
> > On Wed, 2012-05-30 at 11:21 -0700, Mohit Anchlia wrote:
> > 
> > > Thanks! I added this and it doesn't return error but I am not getting  
> > > my document back that matches the following criteria:
> > 
> > I bet your 'name' field is analyzed, but you're using a term query on  
> > it, which looks for the exact value.
> > 
> > Set the 'name' field to { index: "not\_analyzed"}
> > 
> > clint
> > 
> > > curl -XGET '[http://dslg1:9200/documents/object/\_search](http://dslg1:9200/documents/object/_search)' -d '{  
> > > "query" : {  
> > > "bool" : {  
> > > "must" : {  
> > > "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }  
> > > },  
> > > "should" : [  
> > > {  
> > > "term" : { "age" : "20" }  
> > > }  
> > > ],  
> > > "minimum\_number\_should\_match" : 1,  
> > > "boost" : 1.0  
> > > }  
> > > }  
> > > }'
> > > 
> > > My document is:
> > > 
> > > { "attributes" : [  
> > > { "base64" : true,  
> > > "encrypted" : true,  
> > > "ssn" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="  
> > > },  
> > > { "base64" : false,  
> > > "encrypted" : false,  
> > > "age" : "20"  
> > > }  
> > > ],  
> > > "version" : 1337298622093  
> > > }
> > > 
> > > On Wed, May 30, 2012 at 11:08 AM, Clinton Gormley  
> > > [clint@traveljury.com](mailto:clint@traveljury.com) wrote:  
> > > On Wed, 2012-05-30 at 10:57 -0700, Mohit Anchlia wrote:  
> > > \> I am getting this error when I try bool query. Did I miss  
> > > something?
> > > 
> > > ```
> > > yes - the bool query should be wrapped in "query": {..... }
> > > >
> > > > # curl -XGET 'http://dslg1:9200/documents/object/_search' -d
> > > '{
> > > > "bool" : {
> > > > "must" : {
> > > > "term" : { "name" :
> > > "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }
> > > > },
> > > > "should" : [
> > > > {
> > > > "term" : { "age" : "20" }
> > > > }
> > > > ],
> > > > "minimum_number_should_match" : 1,
> > > > "boost" : 1.0
> > > > }
> > > > }'
> > > >
> > > >
> > > > {"error":"SearchPhaseExecutionException[Failed to execute
> > > phase
> > > > [query], total failure; shardFailures
> > > > {[mRAEhEG6QHKNKPEeS0DAWg][documents][1]:
> > > > SearchParseException[[documents][1]: from[-1],size[-1]:
> > > Parse Failure
> > > > [Failed to parse source [{\n \"bool\" : {\n \"must
> > > \" : {\n
> > > > \"term\" : { \"name\" : \"EAAgfyaxpzdfcfv9Qexq1WtGvA==
> > > \" }\n },
> > > > \n \"should\" : [\n {\n
> > > \"term\" :
> > > > { \"age\" : \"20\" }\n }\n ],\n
> > > > \"minimum_number_should_match\" : 1,\n \"boost\" :
> > > 1.0
> > > > \n }\n}]]]; nested: SearchParseException[[documents][1]:
> > > > from[-1],size[-1]: Parse Failure [No parser for element
> > > > [bool]]]; }{[mkOicZNhSga8omWsigTWuw][documents][0]:
> > > >
> > > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];
> > > 
> > > ```
> > 
> > nested: SearchParseException[[documents][0]: from[-1],size[-1]: Parse  
> > Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> > {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term"  
> > : { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][0]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]];  
> > }{[mRAEhEG6QHKNKPEeS0DAWg][documents][2]:  
> > SearchParseException[[documents][2]: from[-1],size[-1]: Parse Failure  
> > [Failed to parse source [{\n "bool" : {\n "must" : {\n  
> > "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term" : {  
> > "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][2]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]];  
> > }{[mkOicZNhSga8omWsigTWuw][documents][4]:  
> > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> > nested: SearchParseException[[documents][4]: from[-1],size[-1]: Parse  
> > Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> > {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term"  
> > : { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][4]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]];  
> > }{[mkOicZNhSga8omWsigTWuw][documents][3]:  
> > RemoteTransportException[[X-Ray][inet[/172.18.62.203:9300]][search/phase/query]];  
> > nested: SearchParseException[[documents][3]: from[-1],size[-1]: Parse  
> > Failure [Failed to parse source [{\n "bool" : {\n "must" :  
> > {\n "term" : { "name" : "EAAgfyaxpzdfcfv9Qexq1WtGvA==" }\n  
> > },\n "should" : [\n {\n "term"  
> > : { "age" : "20" }\n }\n ],\n  
> > "minimum\_number\_should\_match" : 1,\n "boost" : 1.0\n  
> > }\n}]]]; nested: SearchParseException[[documents][3]: from[-1],size[-1]:  
> > Parse Failure [No parser for element [bool]]]; }]","status":500}[root@dslg2~]#
> > 
> > > ```
> > > >
> > > 
> > > ```

---

<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/booleanquery-returning-error/7917/7 "2017-07-06T03:26:14Z")

</div>


