Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
投影后mongodb不能正确排序_Mongodb - Fatal编程技术网

投影后mongodb不能正确排序

投影后mongodb不能正确排序,mongodb,Mongodb,我正在尝试mongoDB v2.6.9。当我尝试投影并排序时,我得到的是该字段的GUID,而不是实际值 以下是查询: db.AuditLogs.aggregate( [ { $project: { "UserName": 1 } }, { $sort: { "UserName": 1 } } ] ) 我得到输出: { "_id" : "562ad0b83811e52f6cae384c", "UserName" : "63889fd9-cc1f-41d9-bf86-0eb2c3a

我正在尝试mongoDB v2.6.9。当我尝试投影并排序时,我得到的是该字段的GUID,而不是实际值

以下是查询:

db.AuditLogs.aggregate( [ { $project: { "UserName": 1 } }, { $sort: { "UserName": 1 } } ] )
我得到输出:

{
    "_id" : "562ad0b83811e52f6cae384c",
    "UserName" : "63889fd9-cc1f-41d9-bf86-0eb2c3ab5be9 e6535140-d11b-4266-b7ba-971b89fa2ad1"
}

用户名应该有字符串数据示例:“first last”

这些GUID是否出现在文档中的某个位置?提供您的AuditLogs模式,并且看起来有两个GUID?下面是一个示例文档:“\u id”:“562ad0b83811e52f6cae304b”“用户名”:“Ben Rich”,“UserIdentifier”:BenRich@test.com,“PortalUserType”:3,“代理标识符”:“测试”,“CustomerIdentifier”:“a99804a6-a7ae-4ac5-93d0-358d1310b71”,“AuditLogEventType”:11,“AuditLogEventAction”:23,“SessionId”:null,“IPAddress”:“111.111.111.111”,“MetaData”:“[\”test.png\“]”,“Source”:“测试”,“ManagementSystemType”:1,“CreatedDate”:ISODate(“2015-09-24T15:58:54.477Z”),“描述”:[“语言”:“英语”,”内容“:“test”,“ShortContent”:“test”}],“SqlId”:474665请用_-id:“562ad0b83811e52f6cae384c”显示记录这些GUID是否出现在您的文档中?提供您的AuditLogs方案,看起来有两个GUID?下面是一个示例文档:“_-id:“562ad0b83811e52f6cae304b”“用户名:“Ben Rich”,“UserIdentifier”:”BenRich@test.com,“PortalUserType”:3,“AgencyIdentifier”:“test”,“CustomerIdentifier”:“a99804a6-a7ae-4ac5-93d0-358d1310b71”,“AuditLogEventType”:11,“AuditLogEventAction”:23,“SessionId”:null,“IPAddress”:“111.111.111.111”,“MetaData”:“[[\“test.png\”]”],“Source”:“test”,“ManagementSystemType”:1,“CreatedDate”:ISODate(“2015-09-24T15:58:54.477Z“,”描述“:[{”语言“:”英语“,”内容“:”测试“,”短内容“:”测试“}],”SqlId“:”474665请显示带有“\u id:”562ad0b83811e52f6cae384c”的记录