Hello ,

I don't feel you can do this in a single call.
What i have in mind would be


   1. Run a two level aggregation query with date histogram aggregation on
   first level with date and term aggregation on second with sum aggregation
   on prize field on second level. You might need to use nested aggregation
   also here.
   2. Once you get the results , choose the dates based on the criteria ,
   i.e. sum of prize more than 300. With the dates you are interested in ,
   fire the next query which has all interesting date ranges as range query.

Thanks
         Vineeth

On Thu, Sep 11, 2014 at 5:04 PM, 闫旭 <[email protected]> wrote:

> Anyone can help this?
>
> Thanks && Best Regard!
>
> 在 2014年9月11日,13:24,闫旭 <[email protected]> 写道:
>
> Thank you !  But nested bool query can not plus all price with the data
> range. how  can i do this??
>
> Thx again.
>
> Thanks && Best Regard!
>
> 在 2014年9月11日,12:04,vineeth mohan <[email protected]> 写道:
>
> Hello ,
>
>
> First you need to declare field details as nested. -
> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html#mapping-nested-type
>
> Then do a bool query with the date range constrain and range constrain
>
> Thanks
>             Vineeth
>
> On Thu, Sep 11, 2014 at 8:53 AM, 闫旭 <[email protected]> wrote:
>
>> Dear All!
>>
>> I have a problem with a complex nested query
>> the docs like this:
>> _id:1
>> {
>> "detail":[
>> {
>> "date":"2014-09-01",
>> "price”:50
>> },
>> {
>> "date":"2014-09-02",
>> "price”:100
>> },
>> {
>> "date":"2014-09-03",
>> "price":100
>> },
>> {
>> "date":"2014-09-04",
>> "price":200
>> }
>> ]
>>
>> }
>> _id:2
>> {
>> "detail":[
>> {
>> "date":"2014-09-01",
>> "price":100
>> },
>> {
>> "date":"2014-09-02",
>> "price":200
>> },
>> {
>> "date":"2014-09-03",
>> "price":300
>> },
>> {
>> "date":"2014-09-04",
>> "price":200
>> }
>> ]
>>
>> }
>> I will filter the docs with “date in [2014-09-01, 2014-09-03] and
>> sum(price) > 300”.
>> I only find some way with “aggregation”, but it can only stat the sum of
>> all docs.
>>
>> How Can I solve the problem??
>>
>>
>> Thanks && Best Regard!
>>
>>
>>
>> --
>> 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/A98354E4-9C9F-43B2-9310-6355DE3D6F85%40gmail.com
>> <https://groups.google.com/d/msgid/elasticsearch/A98354E4-9C9F-43B2-9310-6355DE3D6F85%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> 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/CAGdPd5kfRarPNNBctvYfHsk52tjD2rxv18aQGqq3Hz0i_2ZxVQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kfRarPNNBctvYfHsk52tjD2rxv18aQGqq3Hz0i_2ZxVQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>  --
> 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/F5848899-E506-470B-AA05-E6A2B1965986%40gmail.com
> <https://groups.google.com/d/msgid/elasticsearch/F5848899-E506-470B-AA05-E6A2B1965986%40gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGdPd5mH%2BSrgrkomvNh9-a-A5gDTjeXCO6DE8uWp32ruNbGPFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to