[Newbie] facet search on nested documents failing

I followed the following links in following wiki's to try out facet search
on nested documents but failed with the following error

WIKI - http://www.elasticsearch.org/guide/reference/mapping/nested-type.html,
http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html

I am trying out this for sometime without any luck or understanding the
nature of the problem.

Please help me out of this issue .

vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST
localhost:9200/kerala -d @createIndex ; echo
{"ok":true,"acknowledged":true}
vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat createIndex
{
"public" : {
"properties" : {
"obj1" : {
"type" : "nested"
}
}
}
}
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST
localhost:9200/kerala/public -d @sampleDoc ; echo
{"ok":true,"_index":"kerala","_type":"public","_id":"hAqFUQlQQzSnTk_3VDr6oQ","_version":1}
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST
localhost:9200/kerala/public -d @sampleDoc ; echo
{"ok":true,"_index":"kerala","_type":"public","_id":"8gEPfNhFQ3ao6nhKvLfXlw","_version":1}
vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat sampleDoc
{
"obj1" : [
{
"name" : "blue",
"count" : 4
},
{
"name" : "green",
"count" : 6
}
]
}
vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat query
{
"nested" : {
"path" : "obj1",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"text" : {"obj1.name" : "blue"}
},
{
"range" : {"obj1.count" : {"gt" : 5}}
}
]
}
}
}
}

vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST
localhost:9200/kerala/public/_search -d @query
{"error":"SearchPhaseExecutionException[Failed to execute phase [query],
total failure; shardFailures {[wyPXb3DjT-WLKRKFTsR5uA][kerala][4]:
RemoteTransportException[[DJ][inet[/192.168.1.2:9302]][search/phase/query]];
nested: SearchParseException[[kerala][4]: from[-1],size[-1]: Parse Failure
[Failed to parse source [{ "nested" : { "path" :
"obj1", "score_mode" : "avg", "query" : {
"bool" : { "must" : [
{ "text" : {"obj1.name" :
"blue"} }, {
"range" : {"obj1.count" : {"gt" : 5}}
} ] } } }}]]]; nested:
SearchParseException[[kerala][4]: from[-1],size[-1]: Parse Failure [No
parser for element [nested]]]; }{[Nk3z-jbdSNGdOgOUiA4UdQ][kerala][0]:
RemoteTransportException[[Redwing][inet[/192.168.1.2:9301]][search/phase/query]];
nested: SearchParseException[[kerala][0]: from[-1],size[-1]: Parse Failure
[Failed to parse source [{ "nested" : { "path" :
"obj1", "score_mode" : "avg", "query" : {
"bool" : { "must" : [
{ "text" : {"obj1.name" :
"blue"} }, {
"range" : {"obj1.count" : {"gt" : 5}}
} ] } } }}]]]; nested:
SearchParseException[[kerala][0]: from[-1],size[-1]: Parse Failure [No
parser for element [nested]]]; }{[wyPXb3DjT-WLKRKFTsR5uA][kerala][3]:
RemoteTransportException[[DJ][inet[/192.168.1.2:9302]][search/phase/query]];
nested: SearchParseException[[kerala][3]: from[-1],size[-1]: Parse Failure
[Failed to parse source [{ "nested" : { "path" :
"obj1", "score_mode" : "avg", "query" : {
"bool" : { "must" : [
{ "text" : {"obj1.name" :
"blue"} }, {
"range" : {"obj1.count" : {"gt" : 5}}
} ] } } }}]]]; nested:
SearchParseException[[kerala][3]: from[-1],size[-1]: Parse Failure [No
parser for element [nested]]]; }{[SJhaK1cERxuctG6ZUM4JMw][kerala][1]:
SearchParseException[[kerala][1]: from[-1],size[-1]: Parse Failure [Failed
to parse source [{ "nested" : { "path" : "obj1",
"score_mode" : "avg", "query" : { "bool" :
{ "must" : [ {
"text" : {"obj1.name" : "blue"}
}, { "range" : {"obj1.count"
: {"gt" : 5}} } ] }
} }}]]]; nested: SearchParseException[[kerala][1]: from[-1],size[-1]:
Parse Failure [No parser for element [nested]]];
}{[wyPXb3DjT-WLKRKFTsR5uA][kerala][2]:
RemoteTransportException[[DJ][inet[/192.168.1.2:9302]][search/phase/query]];
nested: SearchParseException[[kerala][2]: from[-1],size[-1]: Parse Failure
[Failed to parse source [{ "nested" : { "path" :
"obj1", "score_mode" : "avg", "query" : {
"bool" : { "must" : [
{ "text" : {"obj1.name" :
"blue"} }, {
"range" : {"obj1.count" : {"gt" : 5}}
} ] } } }}]]]; nested:
SearchParseException[[kerala][2]: from[-1],size[-1]: Parse Failure [No
parser for element [nested]]]; }]","status":500}

Hi Vineeth

It is much easier to read your code if they are gisted, not included in
the email.

Have a look at Elasticsearch Platform — Find real-time answers at scale | Elastic for some advice about
how to ask questions in a way that people are likely to answer them

{
"nested" : {
"path" : "obj1",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"text" : {"obj1.name" : "blue"}
},
{
"range" : {"obj1.count" : {"gt" : 5}}
}
]
}
}
}
}

You are missing a top level 'query' param. So the 'nested' element
should be wrapped in { query: { nested: ... }}

clint

Thanks Clinton ,

One of the issues were that , i will strictly follow the guidelines when i
post another question.

One of the issues were that i didn't use _mapping to apply obj1 as nested.

Thanks
Vineeth

On Tue, Nov 8, 2011 at 12:23 AM, Clinton Gormley clint@traveljury.comwrote:

Hi Vineeth

It is much easier to read your code if they are gisted, not included in
the email.

Have a look at Elasticsearch Platform — Find real-time answers at scale | Elastic for some advice about
how to ask questions in a way that people are likely to answer them

{
"nested" : {
"path" : "obj1",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"text" : {"obj1.name" : "blue"}
},
{
"range" : {"obj1.count" : {"gt" : 5}}
}
]
}
}
}
}

You are missing a top level 'query' param. So the 'nested' element
should be wrapped in { query: { nested: ... }}

clint

oops sorry for the weired text :slight_smile:
What i meant was that

"i will strictly follow the guidelines when i post another question.

One of the issues were that i didn't use _mapping to apply obj1 as nested."

On Tue, Nov 8, 2011 at 8:12 AM, Vineeth Mohan vineethmohan@algotree.comwrote:

Thanks Clinton ,

One of the issues were that , i will strictly follow the guidelines when
i post another question.

One of the issues were that i didn't use _mapping to apply obj1 as nested.

Thanks
Vineeth

On Tue, Nov 8, 2011 at 12:23 AM, Clinton Gormley clint@traveljury.comwrote:

Hi Vineeth

It is much easier to read your code if they are gisted, not included in
the email.

Have a look at Elasticsearch Platform — Find real-time answers at scale | Elastic for some advice about
how to ask questions in a way that people are likely to answer them

{
"nested" : {
"path" : "obj1",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"text" : {"obj1.name" : "blue"}
},
{
"range" : {"obj1.count" : {"gt" : 5}}
}
]
}
}
}
}

You are missing a top level 'query' param. So the 'nested' element
should be wrapped in { query: { nested: ... }}

clint

On Tue, 2011-11-08 at 08:28 +0530, Vineeth Mohan wrote:

oops sorry for the weired text :slight_smile:
What i meant was that

"i will strictly follow the guidelines when i post another question.

:slight_smile:

Just to say: I wasn't saying "bad bad boy!", but rather, if the code is
easy to read (ie gisted) then it is more likely that people will read
it, and thus answer.

glad you found the solution

c

One of the issues were that i didn't use _mapping to apply obj1 as
nested."

On Tue, Nov 8, 2011 at 8:12 AM, Vineeth Mohan
vineethmohan@algotree.com wrote:
Thanks Clinton ,

    One of the issues were that  , i will strictly follow the
    guidelines when i post another question.
    
    One of the issues were that i didn't use _mapping to apply
    obj1 as nested.
    
    Thanks
               Vineeth
    
    
    
    On Tue, Nov 8, 2011 at 12:23 AM, Clinton Gormley
    <clint@traveljury.com> wrote:
            Hi Vineeth
            
            It is much easier to read your code if they are
            gisted, not included in
            the email.
            
            Have a look at http://www.elasticsearch.org/help for
            some advice about
            how to ask questions in a way that people are likely
            to answer them
            
            > {
            >     "nested" : {
            >         "path" : "obj1",
            >         "score_mode" : "avg",
            >         "query" : {
            >             "bool" : {
            >                 "must" : [
            >                     {
            >                         "text" : {"obj1.name" :
            "blue"}
            >                     },
            >                     {
            >                         "range" : {"obj1.count" :
            {"gt" : 5}}
            >                     }
            >                 ]
            >             }
            >         }
            >     }
            > }
            
            
            You are missing a top level 'query' param.  So the
            'nested' element
            should be wrapped in { query: { nested: ... }}
            
            clint