aggregation

Managing ranges with LINQ challenge

故事扮演 提交于 2019-12-13 03:41:23
问题 Given the following numbers (representing days of week): 1,2,3,4,5,6,7 . Here are some combination examples and their desired output: 1,2,3,5,6,7 -> 1-3,5-7 1,3,5,7 -> 1,3,5,7 1,2,5,6 -> 1,2,5,6 1,2,3,6,7 -> 1-3,6,7 The idea is that 3 or more consecutive days become a range while single or non-following days are rendered separately (or is it nicer to make range starting from 2). I don't know where to start should I write a complicated if ed function or this can be done with one of the LINQ

Table aggregation using linq (calculate Average value)

落爺英雄遲暮 提交于 2019-12-13 01:43:33
问题 How to Aggregate below table using linq query Date tagname value 06-06-2018 14:15:00 Poll.Registers Block 0.310-PT-304_(4) 54.73497 06-06-2018 14:15:00 Poll.Registers Block 0.310-PT-304_(5) 3.417564 06-06-2018 14:15:00 Poll.Registers Block 0.310-PT-304_(4) 94.82829 06-06-2018 14:15:00 Poll.Registers Block 0.310-PT-304_(4) 15.08091 06-06-2018 14:15:00 Poll.Registers Block 0.310-PT-304_(5) 3.6422 06-06-2018 14:15:00 Poll.Registers Block 0.310-PT-304_(4) 5.078211 06-06-2018 14:15:00 Poll

Elasticsearch Query aggregated by unique substrings (email domain)

谁说胖子不能爱 提交于 2019-12-12 11:12:07
问题 I have an elasticsearch query that queries over an index and then aggregates based on a specific field sender_not_analyzed . I then use a term aggregation on that same field sender_not_analyzed which returns buckets for the top "senders". My query is currently: { "size": 0, "query": { "regexp": { "sender_not_analyzed": ".*[@].*" } }, "aggs": { "sender-stats": { "terms": { "field": "sender_not_analyzed" } } } } which returns buckets that look like: "aggregations": { "sender-stats": { "buckets"

Elasticsearch aggregation on distinct keys

眉间皱痕 提交于 2019-12-12 10:54:38
问题 I want to aggregate my documents over the different keys in the field "categories". Here are two documents: "date": 1470271301, "categories": { "1": [blabla], "2": [blala] } "date": 144343545, "categories": { "1": [blabla], "2": [coco] "3": [rat, saouth] } Mapping for categories: "categories" : { "properties" : { "1" : { "type" : "long" And i want get something like this: "buckets" : [ { "key" : "1", "doc_count" : 2 }, { "key" : "2", "doc_count" : 2 { "key" : "3", "doc_count" : 1 } Is there a

Composition: using traits to avoid forwarding functions?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 10:32:31
问题 Let's say we have two classes, A and B . When using composition to model a "has-a" or "is-implemented-in-terms-of" relationship (e.g. B has-a A ), one of the drawbacks vs. inheritance is that B does not the contain public functionality of A that it requires. In order to gain access to A s public functions, it is necessary to provide forwarding functions (as opposed to inheritance, where B would inherit all of A s public functions). To give a more concrete example, let's say we have a Person

Filtered nested aggregation in ElasticSearch?

浪子不回头ぞ 提交于 2019-12-12 06:18:37
问题 I have following document list in ElasticSearch (where scores are nested ): { 'type': 'typeA', 'scores': [ {'type': 'A', 'val': 45}, {'type': 'A', 'val': 55}, {'type': 'B', 'val': 65}, ] }, { 'type': 'typeA', 'scores': [ {'type': 'A', 'val': 55}, {'type': 'A', 'val': 50}, {'type': 'A', 'val': 57}, ] }, { 'type': 'typeB', 'scores': [ {'type': 'B', 'val': 40}, {'type': 'A', 'val': 50}, {'type': 'A', 'val': 60}, ] } Is it possible to have a query that returns average scores per type , but only

Elastic search aggregation pagination issue

泄露秘密 提交于 2019-12-12 03:32:28
问题 How do i perform a query similar to this one in elasticsearch? SELECT field FROM table GROUP BY field OFFSET 10 LIMIT 10; Thank for the answer 回答1: The short answer is that you can't (yet). There's an open issue titled "Paging aggregation support" that should take care of this feature soon. As you can see that issue is two years old, still open and got many +1 from many people. It's still not slated for any releases yet, though. In the meantime, you can retrieve your aggregation with size: 20

Avoiding empty and small groups when using pretty_breaks with cut2

为君一笑 提交于 2019-12-12 03:07:46
问题 I'm working with variables resembling the data val values created below: # data -------------------------------------------------------------------- data("mtcars") val <- c(mtcars$wt, 10.55) I'm cutting this variable in the following manner: # Cuts -------------------------------------------------------------------- cut_breaks <- pretty_breaks(n = 10, eps.correct = 0)(val) res <- cut2(x = val, cuts = cut_breaks) which produces the following results: > table(res) res [ 1, 2) [ 2, 3) [ 3, 4) [

Elastic Search multi-value field aggregation

喜欢而已 提交于 2019-12-11 20:47:12
问题 My indexed documents have a schema: { ... 'authors': [{'first name': 'John', 'last name': 'Smith'}, {'first name': 'Mark', 'last name': 'Spencer'}] ... } I would like to search them and aggregate by the individual authors, so get a list with top authors which occurred in my hits. Terms aggregation seems to be a match for my needs, but I'm not able to get it working for field with a list of values. Any help? 回答1: You will probably want to use a nested type, then you can use a nested

In spark iterate through each column and find the max length

雨燕双飞 提交于 2019-12-11 17:55:46
问题 I am new to spark scala and I have following situation as below I have a table "TEST_TABLE" on cluster(can be hive table) I am converting that to dataframe as: scala> val testDF = spark.sql("select * from TEST_TABLE limit 10") Now the DF can be viewed as scala> testDF.show() COL1|COL2|COL3 ---------------- abc|abcd|abcdef a|BCBDFG|qddfde MN|1234B678|sd I want an output like below COLUMN_NAME|MAX_LENGTH COL1|3 COL2|8 COL3|6 Is this feasible to do so in spark scala? 回答1: Plain and simple: