异常信息

repl_test:PRIMARY> db.0917order_totals_b.find()
2018-09-28T15:13:03.992+0800 E QUERY [main] SyntaxError: identifier starts immediately after numeric literal @(shell):1:2
repl_test:PRIMARY> db.0917order_totals_b.find({})
2018-09-28T15:13:13.464+0800 E QUERY [main] SyntaxError: identifier starts immediately after numeric literal @(shell):1:2

情景还原

【使用mapReduce统计指定时间戳区间的交易行为总数】

聚合,统计0917消费金额总和
Aggregation — MongoDB Manual https://docs.mongodb.com/manual/aggregation/
db.accounting_center_orders.mapReduce(function(){emit(this.service_id,this.val)},function(key,values){return Array.sum(values)},{query:{create_timestamp:{$lt:1537200000,$gt:1537113600}},out:"0917order_totals"})
{
"result" : "0917order_totals",
"timeMillis" : 978,
"counts" : {
"input" : 78010,
"emit" : 78010,
"reduce" : 2828,
"output" : 14
},
"ok" : 1
}
结果新建集合
repl_test:PRIMARY> show collections
0917order_totals
Analyse_consume
db.accounting_center_orders.mapReduce(function(){emit(this.service_id,this.val)},function(key,values){return Array.sum(values)},{query:{create_timestamp:{$lt:1537200000,$gt:1537113600}}})
mapReduce 需要指明结果的输出集合名
repl_test:PRIMARY> db.accounting_center_orders.mapReduce(function(){emit(this.service_id,this.val)},function(key,values){return Array.sum(values)},{query:{create_timestamp:{$lt:1537200000,$gt:1537113600}}})
2018-09-28T15:00:07.163+0800 E QUERY [main] TypeError: c.out is undefined :
DBCollection.prototype.mapReduce@src/mongo/shell/collection.js:1401:1
@(shell):1:1
 
 
查询其他集合返回预期信息
 

repl_test:PRIMARY> db.0917order_totals_b.find()
2018-09-28T15:16:25.627+0800 E QUERY [main] SyntaxError: identifier starts immediately after numeric literal @(shell):1:2

2节点主备复制集

[root@e ~]# cat /usr/local/mongodb/conf/mongod.conf
bind_ip=10.14.14.12
port=27017
dbpath=/mnt/mongodb_data/data
logpath=/mnt/mongodb_data/log/mongod.log
pidfilepath=/usr/local/mongodb/mongo.pid
fork=true
logappend=true
shardsvr=true
directoryperdb=true
replSet=repl_test
keyFile=/usr/local/mongodb/conf/keyFile
[root@e ~]#

删除集合报同样错误

repl_test:PRIMARY> db.0917order_totals.drop()
2018-09-28T15:27:20.825+0800 E QUERY [main] SyntaxError: identifier starts immediately after numeric literal @(shell):1:2
repl_test:PRIMARY>

变换命名

repl_test:PRIMARY> db.accounting_center_orders.mapReduce(function(){emit(this.service_id,this.val)},function(key,values){return Array.sum(values)},{query:{create_timestamp:{$lt:1537200000,$gt:1537113600}},out:"order_totalsMR"})
{
"result" : "order_totalsMR",
"timeMillis" : 905,
"counts" : {
"input" : 78010,
"emit" : 78010,
"reduce" : 2828,
"output" : 14
},
"ok" : 1
}
repl_test:PRIMARY> show collections

order_totalsMR

repl_test:PRIMARY> db.order_totalsMR.find()
{ "_id" : 0, "value" : 2472975 }
{ "_id" : 1, "value" : -316177.25 }
{ "_id" : 2, "value" : -211655 }
{ "_id" : 4, "value" : -189450 }
{ "_id" : 7, "value" : -7750 }
{ "_id" : 8, "value" : -194385 }
{ "_id" : 10, "value" : -10000 }
{ "_id" : 11, "value" : -184954.40000000005 }
{ "_id" : 13, "value" : -35050 }
{ "_id" : 16, "value" : -30000 }
{ "_id" : 19, "value" : -6000 }
{ "_id" : 20, "value" : -1329.9999999999998 }
{ "_id" : 21, "value" : -361475 }
{ "_id" : 22, "value" : -600 }
repl_test:PRIMARY>

得到预期输入

【 集合命名规范 :英文字母开头】

 
 
 
 

E QUERY [main] SyntaxError: identifier starts immediately after numeric literal mongodb mapReduce 异常分析 集合命名规范的更多相关文章

  1. Js 抱错:::SyntaxError: identifier starts immediately after numeric literal

    SyntaxError: identifier starts immediately after numeric literal 今天写了个onclick()方法,有这样的一个变量4028b88161 ...

  2. 错误:SyntaxError: identifier starts immediately after numeric literal

    转载:http://blog.csdn.net/shalousun/article/details/39995443在用JavaScript时,当你使用一个字符传作为函数的参数常常会看到语法错误,在f ...

  3. js 传参报错 参数含有数字、字母组合的字符串SyntaxError: identifier starts immediately after numeric literal

    报错的意思是标识符以数字开头,这是因为js是弱类型的语言当发现第一个数字是就自动转化为数字类型的但是其中还含有字符所以报了错,‘ 报错的原因是因为我们想传的字符串,但是js却当成数字,所以需要给传的参 ...

  4. SyntaxError:identifier starts immediately after numeric literal

    1.错误描写叙述 2.错误原因 因为在改动方法传參的过程,须要传个id,可是这个id是字符串类型,传入的是数值型 3.解决的方法 在传參时,须要加入"",变成字符串类型 User. ...

  5. 使用onclick报SyntaxError: identifier starts immediately after numeric literal

    少了‘’ 错误 onclick="onlineWatch(${row.title})" 正确 onclick="onlineWatch('${row.title}')&q ...

  6. jQuery 事件函数传参异常identifier starts immediately after numeric literal

    问题情境: var arr=[aabbcc,112233]; var html = ""; for(var i =0;i<arr.length;i++){ html += ' ...

  7. javascript中出现identifier starts immediately after numeric literal错误原因以及解决方法

    javascript遇到参数是字符型和数字型组合的参数就会出现这种错误,例如alert(1);可以正確輸出alert(str);就會報錯alert("str");可以正確輸出.

  8. org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session异常解决办法

    org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread ...

  9. presto——java.sql.SQLException: Error executing query与javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?异常问题

    使用presto的时候以mysql为presto的数据源 安装的presto是0.95版本:使用的presto-jdbc是0.202的,这里使用jdbc去访问时候,connection可以链接成功,但 ...

随机推荐

  1. android 完美的tabhost 切换多activity布局

    TabHost在很多应用都会使用到,有时候在TabHost添加的Tab中设置view不能满足需求,因为在view中添加如PreferenceActivity相当困难. 之前在一个应用中需要实现使用Ta ...

  2. NodeJS在CentOs7下安装

    node下载地址:https://nodejs.org/en/download/ 1.安装gcc $ yum install gcc-c++ 2.解压最新版本 $ mkdir /usr/local/n ...

  3. Spring核心项目及微服务架构方向

    spring 顶级项目:Spring IO platform:用于系统部署,是可集成的,构建现代化应用的版本平台,具体来说当你使用maven dependency引入spring jar包时它就在工作 ...

  4. mvc5整合Autofac

    本文中将使用 mvc5与webapi2进行对Autofac整合 准备工作: 1.vs2013 or vs2013+ 2.网络良好,nuget正常访问 好了需要的准备工作就这么多. ---------- ...

  5. ViewStub 的使用

    一.内容概述 举例说明ViewStub标签的使用 二.ViewStub类的文档说明及应用场举例 文档描述: A ViewStub is an invisible, zero-sized View th ...

  6. java线程不安全类与写法

    线程不安全类 1.为什么java里要同时提供stringbuilder和stringbuffer两种字符串拼接类 2.simpledateformate是线程不安全的类,如果把它作为全局变量会有线程安 ...

  7. 设计模式之迪米特原则(LoD)

    迪米特原则也叫作最少知识原则,也就是:一个对象应该对其他对象有最少的了解.也就是说一个对象应该尽量的保证高内聚性,不应该对外有太多的public方法.

  8. mvn test中文乱码处理

    mvn test执行测试的时候调用的实际是maven-surefire-plugin插件因为mvn启动时会新建一个jvm进程,默认没有指定编码所以中文乱码了.启动时`<argLine>-D ...

  9. libubox组件(2)——blob/blobmsg (转载 https://segmentfault.com/a/1190000002391970)

    一:blob相关接口 1.数据结构 1: struct blob_attr { 2: uint32_t id_len; /** 高1位为extend标志,高7位存储id, 3: * 低24位存储dat ...

  10. mysql explain的解释

    详解MySQL中EXPLAIN解释命令 explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. 使用方法,在select语句前加上e ...