Bool query on nested objects

hi,

I've following document structure:

curl -XPUT http://localhost:9200/lowang/product/1 -d '
{
"_id":1,
"title":"T-shirt",
"offers": [
{
"price": 10,
"properties":[{"color":"red"}]
},
{
"price": 12,
"properties":[{"color":"black"}]
}
]
}'

and I want to find products that are red t-shirts priced at 12 - in
above example such product doesn't exist.
I ended with following query:

curl -XGET 'http://ds3:9200/lowang/product/_search?pretty=true' -d '{
"query": {
"bool" : {
"must" : [
{
"query_string" : {
"query" : "offers.properties.color = red"
}
},
{
"query_string" : {
"query" : "offers.price = 12"
}
}
]
}
}
}'

however it's returning result, while I was expecting it to fail. What
I really need to do is to have AND operator working on single offer,
how can I accomplish that ?

This is because there is no concept of "compound" structure in the document created. So it matches on both. The parent child feature supports that, but it still missing some features to get what you want (like getting the children back).
On Sunday, January 9, 2011 at 10:43 AM, Przemyslaw Wroblewski wrote:

hi,

I've following document structure:

curl -XPUT http://localhost:9200/lowang/product/1 -d '
{
"_id":1,
"title":"T-shirt",
"offers": [
{
"price": 10,
"properties":[{"color":"red"}]
},
{
"price": 12,
"properties":[{"color":"black"}]
}
]
}'

and I want to find products that are red t-shirts priced at 12 - in
above example such product doesn't exist.
I ended with following query:

curl -XGET 'http://ds3:9200/lowang/product/_search?pretty=true' -d '{
"query": {
"bool" : {
"must" : [
{
"query_string" : {
"query" : "offers.properties.color = red"
}
},
{
"query_string" : {
"query" : "offers.price = 12"
}
}
]
}
}
}'

however it's returning result, while I was expecting it to fail. What
I really need to do is to have AND operator working on single offer,
how can I accomplish that ?