BooleanQuery returning error

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

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 ~]#

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 ~]#

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' -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.comwrote:

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~]#

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' -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 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 ~]#
    >

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

curl -XPOST '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' -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.comwrote:

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' -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 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~]#

    >

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

Thanks for your help!!

curl -XPOST '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.comwrote:

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

curl -XPOST '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' -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.comwrote:

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' -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 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~]#

    >