Unable to set bounds to date histogram query


(K.Samanth Kumar Reddy) #1

Hi,

I am using elasticsearch for last 3 months. It is really good for searching
the billions of docs.
I have created an 'order' index and the document contains the 'orders'
array. Please find the use case below.

Use Case: Get orders created in terms of Price and Count over a period of
time month wise.
Ex:- I want the result only for last one year. I tried the following query.
It is giving the result, but I am getting for all the years instead of last
one year..

Can anybody please help me?

{
"aggregations" : {
"orders" : {
"nested" : {
"path" : "orders"
},
"aggregations" : {
"date_histo" : {
"date_histogram" : {
"field" : "orders.created_date",
"interval" : "1M",
"extended_bounds" : {
"min" : "now-1y/d",
"max" : "now"
}
},
"aggregations" : {
"tot_size" : {
"sum" : {
"field" : "orders.price"
}
}
}
}
}
}
}
}

Thanks & Regards,
Samanth

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b66904a8-2906-4fb3-ad86-fc648a40f57b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(vineeth mohan-2) #2

Hello Samnath ,

You are looking at the wrong area.
Aggregation merely aggregates results from your query.
You need to build a query which will define what would be result.
You need to use the range query -
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-range-query.html

Thanks
Vineeth

On Sat, Jul 12, 2014 at 10:04 PM, K.Samanth Kumar Reddy <
samanthkumar.k@gmail.com> wrote:

Hi,

I am using elasticsearch for last 3 months. It is really good for
searching the billions of docs.
I have created an 'order' index and the document contains the 'orders'
array. Please find the use case below.

Use Case: Get orders created in terms of Price and Count over a period of
time month wise.
Ex:- I want the result only for last one year. I tried the following
query. It is giving the result, but I am getting for all the years instead
of last one year..

Can anybody please help me?

{
"aggregations" : {
"orders" : {
"nested" : {
"path" : "orders"
},
"aggregations" : {
"date_histo" : {
"date_histogram" : {
"field" : "orders.created_date",
"interval" : "1M",
"extended_bounds" : {
"min" : "now-1y/d",
"max" : "now"
}
},
"aggregations" : {
"tot_size" : {
"sum" : {
"field" : "orders.price"
}
}
}
}
}
}
}
}

Thanks & Regards,
Samanth

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/b66904a8-2906-4fb3-ad86-fc648a40f57b%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/b66904a8-2906-4fb3-ad86-fc648a40f57b%40googlegroups.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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5m0%3Dh96VFhNW3wcWmXiMRDuDoN2Mn_u6J9K3HPsVhOa5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3