小编Mik*_*how的帖子

mongoDb:找不到索引来验证连接字段是否唯一

嘿,我需要合并我的两个集合,但 mongo 返回“无法找到索引来验证连接字段是否唯一”

1.创建唯一索引 2.删除whenMatched/whenNotMatched

db.getCollection("GeoLite2-City-Blocks-IPv4").aggregate([
    {$match:{longitude:{$gt:175,$lt:180}}},
    {$merge:{
        into:"GeoLite2-City-Locations-ja",
        on:"geoname_id",
        whenMatched: "replace",
        whenNotMatched: "insert" 
    }}
])
Run Code Online (Sandbox Code Playgroud)

预期:返回 GeoLite2-City-Blocks-IPv4 包括 GeoLite2-City-Locations-ja

merge aggregate unique-index mongodb

2
推荐指数
1
解决办法
8064
查看次数

标签 统计

aggregate ×1

merge ×1

mongodb ×1

unique-index ×1