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 [email protected].
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.