Parent/Child combination Script possible?

Hello,

I have two document types which are utilizing a parent/child relation. I
want to perform an aggregation where the script utilizes fields from both
documents. Is that possible?

More specifically:

Parent Document

{

"tag:{
"_id": {
"path": "tag_id"
},
"properties": {
"tag_id": {"index": "not_analyzed","type": "string"},
"name": {"index": "not_analyzed","type": "string"}
"tag_counter": {"type": "integer"}
}
}
}

Child Document

{

"click:{
"_parent": {
"type": "tag"
},
"properties": {
"type": {"index": "not_analyzed","type": "string"},
"clicks_counter": {"type": "integer"}
}
}
}

curl -XGET "http://localhost:9200/tags-index/tags,clicks/_search" -d'

{
"aggregations": {
"one_day_filter": {
"filter": {
"range": {
"ts": {
"gte": "2014-03-15T00:00:00",
"lt": "2014-03-15T01:00:00"
}
}
},
"aggregations": {
"parent": {
"filter": {
"has_child": {
"type": "clicks",
"query": {
"match_all": {}
}
}
},
"aggregations": {
"metrics": {
"terms": {
"script": "doc["tags.tag_counter"].value -
"doc["clicks.clicks_counter"].value
"
}
}
}
}
}
}
}
},
"size": 0
}'

Thanks
Thomas

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3ffee913-9e82-4862-befe-e0f7ff9038e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I am interested in this also, because this could solve my problem also:
https://groups.google.com/d/topic/elasticsearch/BmxECoKM__I/discussion

regards,

Sven

On Friday, April 11, 2014 5:53:08 PM UTC+2, Thomas wrote:

Hello,

I have two document types which are utilizing a parent/child relation. I
want to perform an aggregation where the script utilizes fields from both
documents. Is that possible?

More specifically:

Parent Document

{

"tag:{
"_id": {
"path": "tag_id"
},
"properties": {
"tag_id": {"index": "not_analyzed","type": "string"},
"name": {"index": "not_analyzed","type": "string"}
"tag_counter": {"type": "integer"}
}
}
}

Child Document

{

"click:{
"_parent": {
"type": "tag"
},
"properties": {
"type": {"index": "not_analyzed","type": "string"},
"clicks_counter": {"type": "integer"}
}
}
}

curl -XGET "http://localhost:9200/tags-index/tags,clicks/_search" -d'

{
"aggregations": {
"one_day_filter": {
"filter": {
"range": {
"ts": {
"gte": "2014-03-15T00:00:00",
"lt": "2014-03-15T01:00:00"
}
}
},
"aggregations": {
"parent": {
"filter": {
"has_child": {
"type": "clicks",
"query": {
"match_all": {}
}
}
},
"aggregations": {
"metrics": {
"terms": {
"script": "doc["tags.tag_counter"].value -
"doc["clicks.clicks_counter"].value
"
}
}
}
}
}
}
}
},
"size": 0
}'

Thanks
Thomas

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2ca1df0f-475e-467e-acb1-32a617b7c8ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thanks Sven,

Yes this would solve a lot of use cases..

Is there anyone that can respond whether we should create an issue for
that? The link provided does not mention whether finally this should be
opened as an issue

Thanks
Thomas

On Friday, 11 April 2014 18:53:08 UTC+3, Thomas wrote:

Hello,

I have two document types which are utilizing a parent/child relation. I
want to perform an aggregation where the script utilizes fields from both
documents. Is that possible?

More specifically:

Parent Document

{

"tag:{
"_id": {
"path": "tag_id"
},
"properties": {
"tag_id": {"index": "not_analyzed","type": "string"},
"name": {"index": "not_analyzed","type": "string"}
"tag_counter": {"type": "integer"}
}
}
}

Child Document

{

"click:{
"_parent": {
"type": "tag"
},
"properties": {
"type": {"index": "not_analyzed","type": "string"},
"clicks_counter": {"type": "integer"}
}
}
}

curl -XGET "http://localhost:9200/tags-index/tags,clicks/_search" -d'

{
"aggregations": {
"one_day_filter": {
"filter": {
"range": {
"ts": {
"gte": "2014-03-15T00:00:00",
"lt": "2014-03-15T01:00:00"
}
}
},
"aggregations": {
"parent": {
"filter": {
"has_child": {
"type": "clicks",
"query": {
"match_all": {}
}
}
},
"aggregations": {
"metrics": {
"terms": {
"script": "doc["tags.tag_counter"].value -
"doc["clicks.clicks_counter"].value
"
}
}
}
}
}
}
}
},
"size": 0
}'

Thanks
Thomas

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9a188e78-e220-4afd-b840-e85ea0cade4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.