Scripting in date histogram


(紫陈) #1

my curl request is
curl -XGET 'http://172.18.216.60:9200/resource/_search?pretty' -d '{
"facets": {
"0": {
"date_histogram": {
"key_field": "timestamp",
"value_script": "doc[\u0027record\u0027].value",
"interval": "12h"
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "01A"
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"fquery": {
"query": {
"field": {
"bid": {
"query": ""110105C999""
}
}
},
"_cache": true
}
},
{
"range": {
"timestamp": {
"from": 1380689917897,
"to": "now+96h"
}
}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
}
}
},
"size": 0
}'

and I get the partial result. Can I get the increment of the field 'record'
during the time range? Thank you
...
{
"time" : 1383264000000,
"count" : 1059,
"min" : 0.008,
"max" : 12.607999999998452,
"total" : 6771.335999999965,
"total_count" : 1059,
"mean" : 6.3940849858356605
}
...

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Alexander Reelsen) #2

Hey,

I dont understand what you mean with 'increment' in that context? Can you
elaborate? What kind of information is missing exactly?

--Alex

On Mon, Nov 11, 2013 at 6:46 AM, 紫陈 zixicc@gmail.com wrote:

my curl request is
curl -XGET 'http://172.18.216.60:9200/resource/_search?pretty' -d '{
"facets": {
"0": {
"date_histogram": {
"key_field": "timestamp",
"value_script": "doc[\u0027record\u0027].value",
"interval": "12h"
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "01A"
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"fquery": {
"query": {
"field": {
"bid": {
"query": ""110105C999""
}
}
},
"_cache": true
}
},
{
"range": {
"timestamp": {
"from": 1380689917897,
"to": "now+96h"
}
}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
}
}
},
"size": 0
}'

and I get the partial result. Can I get the increment of the field
'record' during the time range? Thank you
...
{
"time" : 1383264000000,
"count" : 1059,
"min" : 0.008,
"max" : 12.607999999998452,
"total" : 6771.335999999965,
"total_count" : 1059,
"mean" : 6.3940849858356605
}
...

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(紫陈) #3

well, thanks.
I mean that when it is timestamp1, the 'record' field's value is record1
and when it is timestamp2, the 'record' field's value is record2
timestamp2>timestamp1, the increment is record2-record1, which means the
change of the value
if the field is just monotone increasing or decreasing, the increment can
be (max-min) or (min-max).
But if the field's value may increase or decrease, I don't know how to get
the increment.
By the way, does ES have other apis to get the 'increment'?
在 2013年11月14日星期四UTC+8下午6时28分14秒,Alexander Reelsen写道:

Hey,

I dont understand what you mean with 'increment' in that context? Can you
elaborate? What kind of information is missing exactly?

--Alex

On Mon, Nov 11, 2013 at 6:46 AM, 紫陈 <zix...@gmail.com <javascript:>>wrote:

my curl request is
curl -XGET 'http://172.18.216.60:9200/resource/_search?pretty' -d '{
"facets": {
"0": {
"date_histogram": {
"key_field": "timestamp",
"value_script": "doc[\u0027record\u0027].value",
"interval": "12h"
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "01A"
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"fquery": {
"query": {
"field": {
"bid": {
"query": ""110105C999""
}
}
},
"_cache": true
}
},
{
"range": {
"timestamp": {
"from": 1380689917897,
"to": "now+96h"
}
}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
}
}
},
"size": 0
}'

and I get the partial result. Can I get the increment of the field
'record' during the time range? Thank you
...
{
"time" : 1383264000000,
"count" : 1059,
"min" : 0.008,
"max" : 12.607999999998452,
"total" : 6771.335999999965,
"total_count" : 1059,
"mean" : 6.3940849858356605
}
...

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4