Top_children and has_child together in query


(deepakkhajuria) #1

Hi,

I have three level schema for index which is like:

conversation
|----message
|-------message_tag

Now if run following query on message, it returns results
correctly.

{
"query": {
"has_child": {
"type": "message",
"query": {
"match_all": {}
}
}
}
}

Now if I put query above in query part of top_children on
conversation, it does not return anything and returns some errors with
200. I am trying to get top conversations with messages having
children.
{
"query": {
"top_children": {
"type": "message",
"score": "sum",
"query": {
"has_child": {
"type": "message_tag",
"query": {
"match_all": {}
}
}
}
}
}
}

Results:
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":
3,"failed":2,"failures":[{"index":"testcompany","shard":
0,"reason":"QueryPhaseExecutionException[[testcompany][0]:
query[score_child[message/conversation]
(filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))-

FilterCacheFilterWrapper(_type:message_tag))))-
FilterCacheFilterWrapper(_type:message))],from[0],size[10]: Query
Failed [Failed to execute child query [score_child[message/
conversation](filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))-
FilterCacheFilterWrapper(_type:message_tag))))-
FilterCacheFilterWrapper(_type:message))]]]; nested: "},
{"index":"testcompany","shard":
1,"reason":"QueryPhaseExecutionException[[testcompany][1]:
query[score_child[message/conversation]
(filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))-
FilterCacheFilterWrapper(_type:message_tag))))-
FilterCacheFilterWrapper(_type:message))],from[0],size[10]: Query
Failed [Failed to execute child query [score_child[message/
conversation](filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))-
FilterCacheFilterWrapper(_type:message_tag))))-
FilterCacheFilterWrapper(_type:message))]]]; nested: "}]},"hits":
{"total":0,"max_score":null,"hits":[]}}

I am new to ElasticSearch, so is this supposed to work or I am doing
something wrong.

Thanks,
Deepak


(deepakkhajuria) #2

Sorry for typo:
the first query is

{
"query": {
"has_child": {
"type": "message_tag",
"query": {
"match_all": {}
}
}
}

On Jun 1, 12:37 pm, deepakkhajuria deep...@gmail.com wrote:

Hi,

I have three level schema for index which is like:

conversation
|----message
|-------message_tag

Now if run following query on message, it returns results
correctly.

{
"query": {
"has_child": {
"type": "message",
"query": {
"match_all": {}
}
}
}

}

Now if I put query above in query part of top_children on
conversation, it does not return anything and returns some errors with
200. I am trying to get top conversations with messages having
children.
{
"query": {
"top_children": {
"type": "message",
"score": "sum",
"query": {
"has_child": {
"type": "message_tag",
"query": {
"match_all": {}
}
}
}
}
}

}

Results:
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":
3,"failed":2,"failures":[{"index":"testcompany","shard":
0,"reason":"QueryPhaseExecutionException[[testcompany][0]:
query[score_child[message/conversation]
(filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))],from[0],size[10]: Query

Failed [Failed to execute child query [score_child[message/
conversation](filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))]]]; nested: "},

{"index":"testcompany","shard":
1,"reason":"QueryPhaseExecutionException[[testcompany][1]:
query[score_child[message/conversation]
(filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))],from[0],size[10]: Query

Failed [Failed to execute child query [score_child[message/
conversation](filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))]]]; nested: "}]},"hits":

{"total":0,"max_score":null,"hits":[]}}

I am new to ElasticSearch, so is this supposed to work or I am doing
something wrong.

Thanks,
Deepak


(Shay Banon) #3

Did not fully understand what you execute, can you gist a full sample? See http://www.elasticsearch.org/help.

On Wednesday, June 1, 2011 at 10:57 PM, deepakkhajuria wrote:

Sorry for typo:
the first query is

{
"query": {
"has_child": {
"type": "message_tag",
"query": {
"match_all": {}
}
}
}

On Jun 1, 12:37 pm, deepakkhajuria <deep...@gmail.com (http://gmail.com)> wrote:

Hi,

I have three level schema for index which is like:

conversation
|----message
|-------message_tag

Now if run following query on message, it returns results
correctly.

{
"query": {
"has_child": {
"type": "message",
"query": {
"match_all": {}
}
}
}

}

Now if I put query above in query part of top_children on
conversation, it does not return anything and returns some errors with
200. I am trying to get top conversations with messages having
children.
{
"query": {
"top_children": {
"type": "message",
"score": "sum",
"query": {
"has_child": {
"type": "message_tag",
"query": {
"match_all": {}
}
}
}
}
}

}

Results:
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":
3,"failed":2,"failures":[{"index":"testcompany","shard":
0,"reason":"QueryPhaseExecutionException[[testcompany][0]:
query[score_child[message/conversation]
(filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))],from[0],size[10]: Query

Failed [Failed to execute child query [score_child[message/
conversation](filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))]]]; nested: "},

{"index":"testcompany","shard":
1,"reason":"QueryPhaseExecutionException[[testcompany][1]:
query[score_child[message/conversation]
(filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))],from[0],size[10]: Query

Failed [Failed to execute child query [score_child[message/
conversation](filtered(ConstantScore(child_filter[message_tag/message]
(filtered(ConstantScore(:))->FilterCacheFilterWrapper(_type:message_tag))))-

FilterCacheFilterWrapper(_type:message))]]]; nested: "}]},"hits":

{"total":0,"max_score":null,"hits":[]}}

I am new to ElasticSearch, so is this supposed to work or I am doing
something wrong.

Thanks,
Deepak


(system) #4