elasticsearch - Elastic search data aggregation -



elasticsearch - Elastic search data aggregation -

having next illustration type in index:

{ "_index": "aggs_20141028", "_type": "aggobj", "_id": "4anpd7zlr5etda7o2i898a", "_version": 1, "_score": 1, "_source": { "userid": 4, "created": "2014-10-28t09:40:22.0652362+02:00", "path": "path_0", "intprop1": 1, "intprop2": 87, "intprop3": 903, "boolprop1": false, "boolprop2": true, "boolprop3": false, "stringprop1": "stringprop_6", "stringprop2": "stringprop_6", "stringprop3": "stringprop_3" } }

how aggregate info in next utilize cases?

aggregate boolprop (count) grouping user, timeperiod (e.g. day, month), filter on startdate aggregate boolprop (count) grouping timeperiod (e.g. day, month), filter on startdate, userid aggregate boolprop (count) grouping contentproperty, timeperiod (e.g. day, month), filter on startdate aggregate intprop (sum) grouping path, timeperiod, filter on startdate

original es documentation quite hard understand... http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html

you don't have field startdate in info - i'm assuming mean created? have 3 boolprop fields boolean - it's not clear how want count them, e.g. counting whether present, true, etc.?

the size field depend on size of info , require tuning.

here's how i'd approach first requirement:

curl -xget 'http://localhost:9200/aggs_20141028/aggobj/_search?pretty' -d '{ "aggs": { "date_filter_agg": { "filter" : { "term": { "created": "2014-10-28t09:40:22.0652362+02:00" }}, "aggs" : { "user_agg" : { "terms": {"size": 0, "field" : "userid"}, "aggs" : { "date_agg": { "date_histogram" : { "field" : "created", "interval" : "month" }, "aggs" : { "boolprop_count": {"sum" : {"script" : "(doc[\"boolprop1\"].value == \"t\" ? 1 : 0) + (doc[\"boolprop2\"].value == \"t\" ? 1 : 0) + (doc[\"boolprop3\"].value == \"t\" ? 1 : 0)"} } }} }}}}}}}'

key things note -

the date filter appears first , run on search results. results grouped userid grouped created info in monthly buckets lastly field calculation of value want returned value last, i.e. count of true boolprop fields.

the answers other requirements should similar.

elasticsearch aggregation

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -