Hi
i have some documents like this

{ 
 date : "2014-01-01",
 "periods" : {
    { "start" : 0 ,  "duration": 55  },
    { "start" : 1 ,  "duration": 55  },

    { "start" : 2 ,  "duration": 55  },

    { "start" : 3 ,  "duration": 55  },

    etc...
  }
}



I do a query on a date range with a statistical facet to get the sum of all 
duration


{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "range": {
          "date": {
            "gte": "2014-01-01",
            "lte": "2014-01-11"
          }
        }
      }
    }
  },
  "facets": {
    "stat1": {
      "statistical": {
        "field": "duration"
      },
      "nested": "periods"
    }
  }
}


this works perfect .
Now i need to get the sum of duration for each day , so i tried by using 
the date_historgram , but i have no luck with it ( i guess because my 
periods is a nested object ) 


here is my try

{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "range": {
          "date": {
            "gte": "2013-01-10",
            "lte": "2013-01-11"
          }
        }
      }
    }
  },
  "facets": {
    "stat1": {
      "statistical": {
        "field": "duration"
      },
      "nested": "periods"
    },
    "stat2": {
      "date_histogram": {
        "key_field": "date",
        "value_field": "duration",
        "interval": "day"
      },
      "nested": "periods"
    }
  }
}


Anyone can help me on this ? Thanks

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/3a65022d-1787-4d1a-aaca-d0f493f54070%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to