aggregation

Missing data in next aggregation stage after $lookup

拟墨画扇 提交于 2019-12-11 15:18:27
问题 thanks for come to my post. I'm new in MongoDB, and I need help with it. I need to select user data from DB, so I have a pretty simple pipeline: const pipeline = [{ $match: { type: 'student', counselorUserName: username }, $project: { username: '$username', email: '$email', phone: '$phone', fullName: '$fullName', gradeLevel: { $switch: { branches: [{ case: { $eq: ['$gradeLevel', '9'] }, then: 'Freshman' }, { case: { $eq: ['$gradeLevel', '10'] }, then: 'Sophomore' }, ], default: "Freshman" } }

Is there any way to aggregate table's data in cassandra 2.1.6?

一曲冷凌霜 提交于 2019-12-11 14:46:37
问题 I am new in Cassandra. I want to aggregate my columns like SUM() , MAX() , etc. So is there any way like functions or query or something that can help me ? 回答1: The CQL (Cassandra Query Language) built into Cassandra 2.1.6 only supports the count() aggregation function. So to do aggregation in Cassandra, there are a few options: Do a query that returns all the rows you want to aggregate, and sum them on the client side in java/python/etc. Write your application to do aggregation of your data

Aggregation or composition or simple association?

…衆ロ難τιáo~ 提交于 2019-12-11 14:39:32
问题 There is one example to explaining associations in UML. A person works for a company; a company has a number offices. But I am unable to understand the relationship between Person, Company, and Office classes. My understanding is: a company consists of many persons as employees but these classes exist independently so that is simple association with 0..* multiplicity on Person class' end a company has many offices and those offices will not exist if there is no company so that is composition

Terms aggregation based on unique key

扶醉桌前 提交于 2019-12-11 13:42:02
问题 I have an index full of documents. Each of them has a key "userid" with a distinct value per user, but each user may have multiple documents. Each user has additional properties (like "color", "animal"). I need to get the agg counts per property which would be: aggs: { colors: { terms: { field: color } }, animals: { terms: { field: animal } } } But I need these counts per unique userid, maybe: aggs: { group-by: { field: userid }, sub-aggs: { colors: { terms: { field: color } }, animals: {

Elasticsearch strange terms aggregation

情到浓时终转凉″ 提交于 2019-12-11 13:33:34
问题 There are strange terms in aggregation, if another mapping contains same property name of different type: MAPPING { "mappings" : { "access" : { "properties" : { "cache" : { "type" : "string" } } }, "foo" : { "properties" : { "foobar" : { "type" : "float" }, "cache" : { "type" : "integer" } } } } } BULK DATA {"create":{"_type":"foo"}} {"foobar":[63.8828,66.3633,221.09,736.824,11.4336],"cache":[0,1536000]} QUERY curl -XGET "http://localhost:9200/test/access/_search?pretty=1" -d '{ query : {

$size in mongodb with Condition

為{幸葍}努か 提交于 2019-12-11 12:55:57
问题 I am using aggregation to fetch the value from two collection, One is folder and another is inspections. I am getting all the data's but am getting Inspection count is 0 My code : mongo.folder.aggregate([ { $lookup: { from: 'inspections', localField: '_id', foreignField: 'projectID', as: 'projectdata' } }, { $match : { $and: [ querydata ] } }, { "$project": { "folder_name" : "$folder_name", "location_name": "$location_name", "architect_name" :"$architect_name", "cover_img": "$cover_img",

How to paging aggregation result in ElasticSearch?

和自甴很熟 提交于 2019-12-11 12:53:29
问题 When I execute the query below, how to paging the aggs results? And is there a method to put the aggs results to hits part in json result? POST http://myElastic.com/test/e1,e2,e3/_search { "aggs":{ "dedup" : { "terms":{ "field": "id" }, "aggs":{ "dedup_docs":{ "top_hits":{ "size":1 } } } } } } 回答1: Based on the below issue on the Elasticsearch github site I don't think what you are asking for is possible: https://github.com/elastic/elasticsearch/issues/4915 Seems like a common request however

Saving associated domain classes in Grails

亡梦爱人 提交于 2019-12-11 12:28:53
问题 I'm struggling to get association right on Grails. Let's say I have two domain classes: class Engine { String name int numberOfCylinders = 4 static constraints = { name(blank:false, nullable:false) numberOfCylinders(range:4..8) } } class Car { int year String brand Engine engine = new Engine(name:"Default Engine") static constraints = { engine(nullable:false) brand(blank:false, nullable:false) year(nullable:false) } } The idea is that users can create cars without creating an engine first,

How to perform multiple aggregation on an object in Elasticsearch using Python?

十年热恋 提交于 2019-12-11 12:11:46
问题 I want to perform date histogram query on my Elasticsearch data which is of the format: datetime,field_obj and field_obj has three fields in it: a,b,c Alongside date histogram aggregation, I want to find the average of field_obj i.e avg(field_a), avg(field_b), avg(field_c) also. I tried working it out like this: res = es.search(index="demo",body={"from": 0, "size": 0, "query": {"match_all": {}}, "aggs": { "date_avg": { "date_histogram": {"field": "datetime","interval": "year"}, "aggs": {"avg

return multiple columns from data.table aggregation [duplicate]

痞子三分冷 提交于 2019-12-11 09:52:39
问题 This question already has an answer here : Create columns from column of list in data.table (1 answer) Closed 6 years ago . I would like to use data.table as an alternative to aggregate() or ddply() , as these two methods aren't scaling to large objects as efficiently as hoped. Unfortunately, I haven't figured out how to get vector-returning aggregate functions to generate multiple columns in the result from data.table . For example: # required packages library(plyr) library(data.table) #