nosql

Skip duplicates on field in a Elasticsearch search result

☆樱花仙子☆ 提交于 2021-02-11 12:29:31
问题 Is it possible to remove duplicates on a given field? For example the following query: { "query": { "term": { "name_admin": { "value": "nike" } } }, "_source": [ "name_admin", "parent_sku", "sku" ], "size": 2 } is retrieving "hits" : [ { "_index" : "product", "_type" : "_doc", "_id" : "central30603", "_score" : 4.596813, "_source" : { "parent_sku" : "SSP57", "sku" : "SSP57816401", "name_admin" : "NIKE U NSW PRO CAP NIKE AIR" } }, { "_index" : "product", "_type" : "_doc", "_id" :

MongoDB concurrent update to same document is not behaving atomic

无人久伴 提交于 2021-02-11 06:55:31
问题 Currently, we have an orderId for which we give the benefit(posting) to the user. There are multiple events that can trigger benefit/posting. But the condition is that only 1 event should be triggered. Hence for handling current requests, we created a boolean field POSTING_EVENT_SENT , initially set to false, and later whoever was able to mark it as true can proceed further. public boolean isOrderLockedAndUpdatedToTriggerPosting(String orderId, OrderStatus orderStatus) { Query query = new

MongoDB concurrent update to same document is not behaving atomic

筅森魡賤 提交于 2021-02-11 06:54:09
问题 Currently, we have an orderId for which we give the benefit(posting) to the user. There are multiple events that can trigger benefit/posting. But the condition is that only 1 event should be triggered. Hence for handling current requests, we created a boolean field POSTING_EVENT_SENT , initially set to false, and later whoever was able to mark it as true can proceed further. public boolean isOrderLockedAndUpdatedToTriggerPosting(String orderId, OrderStatus orderStatus) { Query query = new

零编码制作报表可能吗?

爷,独闯天下 提交于 2021-02-10 18:33:47
要回答这个问题,首先要明确啥程度算“零编码”? 以 Excel 为例,如果把写 Excel 公式(包括复杂一些的)看做零编码;而把写 Excel VBA 看做编码的话, 报表开发是可以零编码的! 但是,这有个前提:在数据(集)准备好的情况下才可以零编码! 为什么这么说? 我们知道报表开发主要分两个阶段: 第一阶段是为报表准备数据,也就是把原始数据通过 SQL/ 存储过程加工成数据集; 第二阶段是使用已准备的数据编写表达式做报表呈现。在报表工具提供的 IDE 里可视化地画出报表样式,然后再填入一些把数据和单元格绑定的表达式就可以完成报表呈现了,虽然表达式可能比较复杂,但相对硬编码要简单得多(Excel 公式和 VBA 的关系)。所以说这个阶段是能做到“零编码”的。 那报表数据准备怎么办? 很遗憾,这个阶段没法零编码,一直以来只能硬编码,想想我们报表里写的嵌套 SQL、存储过程、JAVA 程序就知道了。为什么报表工具发展这么多年报表呈现已经完全工具化而报表数据准备的手段还这样原始呢?因为这个阶段太复杂了,不仅涉及计算逻辑的算法实现,还涉及报表性能(要知道大部分报表性能问题都是数据准备阶段引起的)。 那报表数据准备是不是没办法了呢? 虽然不能做到零编码,但可以朝着简单化的方向努力,将数据准备阶段也工具化,这样可以使用工具提供的便利来简化报表数据准备阶段的工作,从而进一步简化报表的开发。

Two Way Embedding vs. One Way Embedding in MongoDB (Many-To-Many)

守給你的承諾、 提交于 2021-02-10 12:13:27
问题 I would like to discuss with you, if it makes any sense to use two way embedding instead of one way embedding, when modeling an N:M relationship in MongoDB. Let's say, we have two entities: A Product can belong to many (few) Categories , and a Category can have many (lots of) Products . Two Way Embedding If we use this approach, our categories would look like this: { _id: 1, name: "Baby", products: [2] } { _id: 2, name: "Electronics", products: [1, 2] } And products : { _id: 1, name: "HDMI

零编码制作报表可能吗?

Deadly 提交于 2021-02-10 07:30:41
要回答这个问题,首先要明确啥程度算“零编码”? 以 Excel 为例,如果把写 Excel 公式(包括复杂一些的)看做零编码;而把写 Excel VBA 看做编码的话, 报表开发是可以零编码的! 但是,这有个前提:在数据(集)准备好的情况下才可以零编码! 为什么这么说? 我们知道报表开发主要分两个阶段: 第一阶段是为报表准备数据,也就是把原始数据通过 SQL/ 存储过程加工成数据集; 第二阶段是使用已准备的数据编写表达式做报表呈现。在报表工具提供的 IDE 里可视化地画出报表样式,然后再填入一些把数据和单元格绑定的表达式就可以完成报表呈现了,虽然表达式可能比较复杂,但相对硬编码要简单得多(Excel 公式和 VBA 的关系)。所以说这个阶段是能做到“零编码”的。 那报表数据准备怎么办? 很遗憾,这个阶段没法零编码,一直以来只能硬编码,想想我们报表里写的嵌套 SQL、存储过程、JAVA 程序就知道了。为什么报表工具发展这么多年报表呈现已经完全工具化而报表数据准备的手段还这样原始呢?因为这个阶段太复杂了,不仅涉及计算逻辑的算法实现,还涉及报表性能(要知道大部分报表性能问题都是数据准备阶段引起的)。 那报表数据准备是不是没办法了呢? 虽然不能做到零编码,但可以朝着简单化的方向努力,将数据准备阶段也工具化,这样可以使用工具提供的便利来简化报表数据准备阶段的工作,从而进一步简化报表的开发。

MongoDB doesn't handle aggregation with allowDiskUsage:True

≯℡__Kan透↙ 提交于 2021-02-10 03:22:29
问题 the data structure is like: way: { _id:'9762264' node: ['253333910', '3304026514'] } and I'm trying to count the frequency of nodes' appearance in ways. Here is my code using pymongo: node = db.way.aggregate([ {'$unwind': '$node'}, { '$group': { '_id': '$node', 'appear_count': {'$sum': 1} } }, {'$sort': {'appear_count': -1}}, {'$limit': 10} ], {'allowDiskUse': True} ) it will report an error: Traceback (most recent call last): File "<input>", line 1, in <module> File ".../OSM Wrangling

极客时间-左耳听风-程序员攻略-数据库

你。 提交于 2021-02-08 23:52:46
对于数据库方向,重点就是两种数据库,一种是以 SQL 为代表的关系型数据库,另一种是以非 SQL 为代表的 NoSQL 数据库。关系型数据库主要有三个:Oracle、MySQL 和 Postgres。 关系型数据库 Oracle,《 Oracle Database 9i/10g/11g 编程艺术 》 这本书中深入分析了 Oracle 数据库体系结构,包括文件、内存结构以及构成 Oracle 数据库和实例的底层进程,利用具体示例讨论了一些重要的数据库主题,如锁定、并发控制、事务等。同时分析了数据库中的物理结构,如表、索引和数据类型,并介绍采用哪些技术能最优地使用这些物理结构。 MySQL 官方手册]( https://dev.mysql.com/doc/ )。 官方几个 PPT 。 How to Analyze and Tune MySQL Queries for Better Performance MySQL Performance Tuning 101 MySQL Performance Schema & Sys Schema MySQL Performance: Demystified Tuning & Best Practices MySQL Security Best Practices MySQL Cluster Deployment Best Practices

Copying a mongo collection with huge data to another collection?

橙三吉。 提交于 2021-02-08 06:13:46
问题 I have a mongo collection(s) with 2.5 million data and that may grow upto 3 million. I am using spring batch and am trying to copy that collection to another collection. Approaches I have used are as follows : Inside a tasklet, I have Created a ProcessBuilder object and called a shell script which executes a mongo query. Content of shell script is as follows : > mongo $serverURL/$dbName js-file-to-execute.js // js file contains copy command (db.collection.copyto('newCollection')) For less

Executing JavaScript file in MongoDB

不羁岁月 提交于 2021-02-08 03:47:27
问题 I would like to know how to execute a JavaScript file in MongoDB. This is the simple piece of code present in my JS file: function loadNames() { print("name"); } From the command prompt I tried to execute the file like this mongo test.js but it shows the error: unexpected identifier Can anyone explain to me where I'm going wrong? 回答1: I usually run my test queries like this, and it works with your sample code too. mongo < test.js 回答2: two meothods to achieve this: 1 . use " --eval " mongo