异常信息

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. 创建支持多种屏幕尺寸的apk

    文章转至:http://hell0android.iteye.com/blog/1899605 创建对两种以上屏幕尺寸的多apk支持(Creating Multiple APKs with 2+ Di ...

  2. Spring事务的传播行为 @Transactional

    Spring事务的传播行为http://blog.csdn.net/cuker919/article/details/5957209 在service类前加上@Transactional,声明这个se ...

  3. 转MQTT SERVER 性能测试报告

    硬件环境: 内存4G CPU4核 SERVER及端口: apollo端口 61619 mosquitto:端口 1884 activeMQ端口:1883 emqtt 端口1885 测试方法 并发测试: ...

  4. Atitit.通过null 参数 反射  动态反推方法调用

    Atitit.通过null 参数 反射  动态反推方法调用 此时,直接使用java  apache的ref工具都失效了.必须要自己实现了. 如果调用接口方法的话,就不能使用apache的ref工具,可 ...

  5. Strategy模式

    Strategy模式 Strategy模式要解决的问题和Template模式类似.都是为了把算法的声明和算法的实现解耦.Template模式是通过继承来实现的,而Strategy模式是通过组合来实现的 ...

  6. [c#.Net] NUnit Test 体验

    NUit Test Adapter 安装,两种方式 第一种:从扩展和更新里搜索nunit,进行下载安装

  7. python剑指网络篇二

    在socket编程中 AF_INET 对应 IPv4 SOCK_STREAM 对应 TCP SOCK_DGRAM 对应 UDP

  8. codeblocks设置当前行高亮

    默认是不开启当前行高亮的. 如果想打开,选择:Settings>Editor>Editor Settings>Other options> 勾选Highlight line u ...

  9. 学习笔记 - Unity是如何将你的项目发布到如此多的平台的?

    很多Unity的开发者是不是都会觉得Unity能把项目导出发布到那么多不同的平台上运行是件很牛X的事情?那么你有没有想过Unity是如何做到的呢?本文就来大体的聊一聊Unity做的这件神奇的事情. 概 ...

  10. git设置及常用命令

    下载 下载地址:https://git-scm.com/downloads windows系统安装 默认安装即可. 其它系统安装方式请自行百度,网上教程很多. 设置 windows桌面右键,选择Git ...