1***@qq.com
1***@qq.com
  • 发布:2024-06-23 11:25
  • 更新:2024-06-23 11:25
  • 阅读:36

【报Bug】聚合搜索对新添加的文档无法搜索

分类:uniCloud

产品分类: uniCloud/App

示例代码:
    db.collection(str).aggregate()  
        .addFields({  
            fullStr: db.command.aggregate.concat(['$stem', ' ', '$choiceA', ' ', '$choiceB', ' ', '$choiceC'])  
        })  
        .match(`${new RegExp(query, 'i')}.test(fullStr)`).limit(100).project({  
            questionid: true  
        }).end().then(res => {  
            uni.hideLoading()  
            let temp = res.result.data  
            itemArr.value = []  
            itemContent.value = {}  
            if (temp.length == 0) {  
                uni.showToast({  
                    title: '未查到相关题目',  
                    icon: "error"  
                })  

            } else {  
                for (let i in temp) {  
                    itemArr.value.push(temp[i].questionid)  
                }  

                itemNum.value = 0  
                getItem(itemArr.value[itemNum.value])  
            }  
        })  

这是聚合搜索的代码,搜题库中的旧题没问题,但是新添加到数据库的题就搜不到

操作步骤:
    db.collection(str).aggregate()  
        .addFields({  
            fullStr: db.command.aggregate.concat(['$stem', ' ', '$choiceA', ' ', '$choiceB', ' ', '$choiceC'])  
        })  
        .match(`${new RegExp(query, 'i')}.test(fullStr)`).limit(100).project({  
            questionid: true  
        }).end().then(res => {  
            uni.hideLoading()  
            let temp = res.result.data  
            itemArr.value = []  
            itemContent.value = {}  
            if (temp.length == 0) {  
                uni.showToast({  
                    title: '未查到相关题目',  
                    icon: "error"  
                })  

            } else {  
                for (let i in temp) {  
                    itemArr.value.push(temp[i].questionid)  
                }  

                itemNum.value = 0  
                getItem(itemArr.value[itemNum.value])  
            }  
        })

预期结果:

能搜到新添加到数据库中的题目

实际结果:

只能搜到原有数据库中的题目,新添加的搜不到

bug描述:

我做了个题目搜索的数据库,大约3500个题目,schema使用了聚合索引题干和选项,搜索时使用聚合搜索,一切正常。
但是后续添加新题时,再用聚合搜索时就搜不到新题,只能搜到原来的旧题。

2024-06-23 11:25 负责人:无 分享
已邀请:

要回复问题请先登录注册