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/3ffee913-9e82-4862-befe-e0f7ff9038e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.