aggregation

MongoDb $addFields and $match

两盒软妹~` 提交于 2019-12-11 00:49:48
问题 In my mongodb query, I use $addFields to add ID field which concatenated of other three fields. My problem is that I get no result if I $match that new added field with value that I want to query. For other fields, they work just fine. order of aggregation what is in aggregation data = await model.aggregate([ { $project: { projectName: 1, price: 1, 'document': '$$ROOT' } }, { $addFields:{ 'document.id': {$concat: ['$document.propertyId.prefix','$document.propertyId.number']} } }, { $match: {

ElasticSearch terms aggregation on tokenized field

孤街醉人 提交于 2019-12-10 23:58:32
问题 when i do terms aggregation on string field (with whitespace tokenizer) i have results for each word (token), but i need results for whole strings. How can i do aggregation on string field like terms but group output by whole string, not by tokens? I already saw this solutions: ElasticSearch term aggregation Terms aggregation based on unique key but they are based on keyword tokenizer I can't use keyword tokenizer, because of i wan't apply stopwords filter while indexing 回答1: I just had the

How to aggregate duplicate records and sum value using C#

空扰寡人 提交于 2019-12-10 22:39:55
问题 I want to create a list where it holds several agents and the number of calls they make and did it like so: public class Agent { public string Agent_ID{ get; set; } public string Name { get; set; } public int Calls { get; set; } } var list = new List<Agent>() // To create a list to hold the data { new Agent() { Agent_ID = "TK_J", Name = "James", Calls = 10 }, new Agent() { Agent_ID = "TK_K", Name = "Kurtis", Calls = 10 }, new Agent() { Agent_ID = "TK_R", Name = "Rebecca", Calls = 5 }, new

ElasticSearch - issue with sub term aggregation with array fields

半腔热情 提交于 2019-12-10 18:18:21
问题 I have the two following documents: { "title":"The Avengers", "year":2012, "casting":[ { "name":"Robert Downey Jr.", "category":"Actor", }, { "name":"Chris Evans", "category":"Actor", } ] } and: { "title":"The Judge", "year":2014, "casting":[ { "name":"Robert Downey Jr.", "category":"Producer", }, { "name":"Robert Duvall", "category":"Actor", } ] } I would like to perform aggregations, based on two fields : casting.name and casting.category. I tried with a TermsAggregation based on casting

Data aggregation and caching: How to quickly graph large time series datasets by interval

我只是一个虾纸丫 提交于 2019-12-10 16:07:31
问题 I have a huge time series dataset that I'd like to graph. The time series spans back 5 years. From a backend standpoint, what are the common approaches to displaying this data at various resolutions (intervals)? Essentially I would like to chart data like this: https://bitcoinwisdom.com/markets/bitstamp/btcusd I'd like to offer the user the ability to select a time interval (seconds, minutes, hours, days, months, years). How is this data typically aggregated and stored? Would I want to store

Data table - apply the same function on several columns to create new data table columns

前提是你 提交于 2019-12-10 16:06:08
问题 I am working with data.table package. I have a data table which represents users actions on a website. Let's say that every user can visit a website, and perform multiple actions on it. My original data table is of actions (every row is an action) and I want to aggregate this information into a new data table, grouped by user visits (every visit has a unique ID). There are some fields which are shared by the actions of the same visit - for example - the user name, the user status, the visit

Restrict ElasticSearch aggregation by type?

爱⌒轻易说出口 提交于 2019-12-10 15:07:03
问题 How do you perform an ElasticSearch aggregation for a specific type? I realize that you can specify the index and/or type in the request Url, but I want to perform aggregations on two distinct types. Thank you! 回答1: You could filter the aggregation by type, and then use sub-aggregations. For example: { "aggs": { "Test 1": { "filter": { "type": { "value": "type1" } }, "aggs": { "agg_name": { "terms": { "field": "field1", "size": 10 } } } }, "Test 2": { "filter": { "type": { "value": "type2" }

Elasticsearch Pipelining through a Child Aggregation

家住魔仙堡 提交于 2019-12-10 11:15:29
问题 I am trying to Sum up Data through a Child Aggregation in Elasticsearch 2.1. With Pipelining i am trying to get the Child Aggregation Data summed up on the Parent Level of the Aggregation: { "query": { "match_all": {} }, "aggs": { "unit": { "terms": { "size": 500, "field": "unit_id" }, "aggs": { "total_active_ministers_by_unit": { "sum_bucket": { "buckets_path": "ministers>active_minister_by_ministry.value" } }, "ministers": { "children": { "type": "member_ministry" }, "aggs": { "active

How to Use pagination (size and from) in elastic search aggregation?

纵然是瞬间 提交于 2019-12-10 11:08:13
问题 How to Use pagination (size and from) in elasticsearch aggregation , I used Size and from in agreggition it,s throw exception for exmaple. I wanna query like? GET /index/nameorder/_search { "size": 0, "query": { "filtered": { "query": { "bool": { "must": [ { "match": { "projectId": "10057" } } ] } }, "filter": { "range": { "purchasedDate": { "from": "2012-02-05T00:00:00", "to": "2015-02-11T23:59:59" } } } } }, "aggs": { "group_by_a": { "terms": { "field": "promocode", "size": 40, "from": 40 }

Understanding UML of DoFactory Design Pattern - Decorator

倖福魔咒の 提交于 2019-12-10 05:47:56
问题 I am trying to understand UML diagram describing Decorator Pattern at link below http://www.dofactory.com/Patterns/PatternDecorator.aspx I don't understand why there is a "Aggregation" relation between Decorator and Component. I believe it should be composition as Decorator cannot exist without the base component. 回答1: Composition is stronger that aggregation, it usually means that the object takes ownership of its components. This is not the case in this situation because a decorator doesn't