Filtering parent documents in has_child query

Hi,
I am trying to understand how the parent-child model works in
elasticsearch. I am able to create parent-child mapping and the
documents. I was able to run the following query

curl-XGET "localhost:9200/test/_search?pretty=true"-d'{
"query": {
"has_child": {
"type": "chld",
"query": {
"term": {
"created": "today"
}
}
}'

and it returns me list of parent documents for the matching children.
I want to filter the matching parent docs further like

curl-XGET "localhost:9200/test/_search?pretty=true"-d'{
"query": {
"has_child": {
"type": "chld",
"query": {
"term": {
"created": "today"
}
}
},
"term": {
"status": "free"
}
}'

Is this possible or is it my query that's not correct?

thanks

You query is not formed correctly, you just put pasted two queries in the "query" element. You need to wrap it in a book query (probably placing both in a must clause).

On Friday, February 24, 2012 at 9:31 PM, venkat wrote:

Hi,
I am trying to understand how the parent-child model works in
elasticsearch. I am able to create parent-child mapping and the
documents. I was able to run the following query

curl-XGET "localhost:9200/test/_search?pretty=true"-d'{
"query": {
"has_child": {
"type": "chld",
"query": {
"term": {
"created": "today"
}
}
}'

and it returns me list of parent documents for the matching children.
I want to filter the matching parent docs further like

curl-XGET "localhost:9200/test/_search?pretty=true"-d'{
"query": {
"has_child": {
"type": "chld",
"query": {
"term": {
"created": "today"
}
}
},
"term": {
"status": "free"
}
}'

Is this possible or is it my query that's not correct?

thanks

That works. thanks.

On Feb 26, 11:35 am, Shay Banon kim...@gmail.com wrote:

You query is not formed correctly, you just put pasted two queries in the "query" element. You need to wrap it in a book query (probably placing both in a must clause).

On Friday, February 24, 2012 at 9:31 PM, venkat wrote:

Hi,
I am trying to understand how the parent-child model works in
elasticsearch. I am able to create parent-child mapping and the
documents. I was able to run the following query

curl-XGET "localhost:9200/test/_search?pretty=true"-d'{
"query": {
"has_child": {
"type": "chld",
"query": {
"term": {
"created": "today"
}
}
}'

and it returns me list of parent documents for the matching children.
I want to filter the matching parent docs further like

curl-XGET "localhost:9200/test/_search?pretty=true"-d'{
"query": {
"has_child": {
"type": "chld",
"query": {
"term": {
"created": "today"
}
}
},
"term": {
"status": "free"
}
}'

Is this possible or is it my query that's not correct?

thanks