Nested objects selection

hello,

I would like to select only some objects in my nasted objects array.
Data comes from (https://gist.github.com/haswalt/a0d78e7c32ec76f03681) :

*curl -XPOST http://localhost:9200/cars/documents/1?pretty=true -d'{
"title": "Test Document 1",
"slug": "test-document-1",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "News",
"slug": "news",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/2?pretty=true -d'{
"title": "Test Document 2",
"slug": "test-document-2",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/3?pretty=true -d'{
"title": "Test Document 3",
"slug": "test-document-3",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/4?pretty=true -d'{
"title": "Test Document 4",
"slug": "test-document-4",
"content": "

Some content

",
"published": 0,
"version": 2,
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/5?pretty=true -d'{
"title": "Test Document 5",
"slug": "test-document-5",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'
curl -XPOST http://localhost:9200/cars/documents/6?pretty=true -d'{
"title": "Test Document 6",
"slug": "test-document-6",
"content": "

Some content

",
"published": "2",
"version": "5",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 102,
"test": "kikou"
},
{
"name": "News",
"slug": "news",
"type": 103
},
{
"name": "test",
"slug": "news",
"type": 104,
"test": "kikou"
}
]
}'
*

here is my query :
curl -XGET http://localhost:9200/cars/documents/_search?pretty=true -d'{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"range": { "published": { "gt": 0 } }
},
{"nested": {
"path": "tags",
"query": {
"filtered": {
"filter": {
"and": [
{
"term": {
"tags.type": "104"
}
},{
"term": {
"tags.test": "kikou"
}
}
]
}
}
}
}
}
]
}
}
}
}
}'

I would like to get only these fields :
"title": "Test Document 6",
"slug": "test-document-6",
"content": "

Some content

",
"published": "2",
"version": "5",
"tags":
{
"name": "test",
"slug": "news",
"type": 104,
"test": "kikou"
}

and not the whole object matching to the conditions. It sounds easy but i'm
breaking my head on it (syntax doesn't help me ...)

Does someone have an idea ?

Regards,

Fabien

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

That functionality is not yet supported:

--
Ivan

On Tue, Jul 2, 2013 at 10:24 AM, Fabien Chung chung.fabien@gmail.comwrote:

hello,

I would like to select only some objects in my nasted objects array.
Data comes from (https://gist.github.com/haswalt/a0d78e7c32ec76f03681) :

*curl -XPOST http://localhost:9200/cars/documents/1?pretty=true -d'{
"title": "Test Document 1",
"slug": "test-document-1",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "News",
"slug": "news",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/2?pretty=true -d'{
"title": "Test Document 2",
"slug": "test-document-2",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/3?pretty=true -d'{
"title": "Test Document 3",
"slug": "test-document-3",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/4?pretty=true -d'{
"title": "Test Document 4",
"slug": "test-document-4",
"content": "

Some content

",
"published": 0,
"version": 2,
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'

curl -XPOST http://localhost:9200/cars/documents/5?pretty=true -d'{
"title": "Test Document 5",
"slug": "test-document-5",
"content": "

Some content

",
"published": "2",
"version": "2",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 101
},
{
"name": "Reviews",
"slug": "reviews",
"type": 102
}
]
}'
curl -XPOST http://localhost:9200/cars/documents/6?pretty=true -d'{
"title": "Test Document 6",
"slug": "test-document-6",
"content": "

Some content

",
"published": "2",
"version": "5",
"tags": [
{
"name": "Cars",
"slug": "cars",
"type": 102,
"test": "kikou"
},
{
"name": "News",
"slug": "news",
"type": 103
},
{
"name": "test",
"slug": "news",
"type": 104,
"test": "kikou"
}
]
}'
*

here is my query :
curl -XGET http://localhost:9200/cars/documents/_search?pretty=true
-d'{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"range": { "published": { "gt": 0 } }
},
{"nested": {
"path": "tags",
"query": {
"filtered": {
"filter": {
"and": [
{
"term": {
"tags.type": "104"
}
},{
"term": {
"tags.test": "kikou"
}
}
]
}
}
}
}
}
]
}
}
}
}
}'

I would like to get only these fields :
"title": "Test Document 6",
"slug": "test-document-6",
"content": "

Some content

",
"published": "2",
"version": "5",
"tags":
{
"name": "test",
"slug": "news",
"type": 104,
"test": "kikou"
}

and not the whole object matching to the conditions. It sounds easy but
i'm breaking my head on it (syntax doesn't help me ...)

Does someone have an idea ?

Regards,

Fabien

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.