Re: date_historgram facet issue

2014-02-06 Thread Samuel Merlet
Just for helping someone if needed , this could be done using aggregations 
of ES 1.x

like this

{
  size: 0, 
   query: {
 filtered: {
query: {
   match_all: {}
}
 }
  },
  aggs: {
 nest_global: {
nested: {
   path: periods
},
aggs: {
   stat2: {
  stats: {
 field: duration
  }
   }
}
 },
 par_date: {
date_histogram: {
   field: date,
   interval: day
},
aggs: {
   nest_par_date: {
  nested: {
 path: periods
  },
  aggs: {
 stat2: {
stats: {
   field: duration
}
 }
  }
   }
}
 }
  }
}


Thanks to Erwan D  from Elastic French Group !


Le mardi 4 février 2014 11:06:56 UTC+1, Samuel Merlet a écrit :

 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/a58ae6f1-1fa4-43d5-b62a-4c6dd436b2d5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


date_historgram facet issue

2014-02-04 Thread samuel . merlet
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.