MongoDB 4.4 版是否支持 $lookup 中的 $text 搜索?
Does MongoDB version 4.4 support $text search within $lookup?
我正在尝试在 $look up 中进行文本搜索。我记得在以前的版本(4.0 版)中这是不可能的。这是我要完成的示例。 MongoDB 4.4 版是否支持 $lookup 中的 $text 搜索?
db.getCollection('recording').aggregate([
{
"$lookup": {
"from": "meeting",
"let": {
"meetingId": "$meeting"
},
"as": "meeting_data",
"pipeline": [
{
"$match": {
"_id": "$$meeting",
"$text": {
"$search": "\"go away\""
}
}
}
]
}
},
{
"$lookup": {
"from": "transcribe",
"let": {
"transcribeId": "$transcribe"
},
"as": "transcribe_data",
"pipeline": [
{
"$match": {
"_id": "$$transcribeId",
"$text": {
"$search": "\"go away\""
}
}
}
]
}
}
])
上一个错误
{
"ok" : 0,
"errmsg" : "pipeline requires text score metadata, but there is no text score available",
"code" : 40218,
"codeName" : "Location40218"
}
我会试试这个,它在 4.4.1
对我来说运行良好。我只是重写了变量:
pipeline = [
{
"$lookup" : {
"from" : "meeting",
"let" : {
"meetingId" : "$meeting"
},
"as" : "meeting_data",
"pipeline" : [
{
"$match" : {
"$expr" : {
"$eq" : [
"$_id",
"$$meetingId"
]
}
},
"$text" : {
"$search" : "\"go away\""
}
}}]
}}]
db.getCollection('recording').aggregate(pipeline)
如果可行,下一阶段遵循相同的思路。
我正在尝试在 $look up 中进行文本搜索。我记得在以前的版本(4.0 版)中这是不可能的。这是我要完成的示例。 MongoDB 4.4 版是否支持 $lookup 中的 $text 搜索?
db.getCollection('recording').aggregate([
{
"$lookup": {
"from": "meeting",
"let": {
"meetingId": "$meeting"
},
"as": "meeting_data",
"pipeline": [
{
"$match": {
"_id": "$$meeting",
"$text": {
"$search": "\"go away\""
}
}
}
]
}
},
{
"$lookup": {
"from": "transcribe",
"let": {
"transcribeId": "$transcribe"
},
"as": "transcribe_data",
"pipeline": [
{
"$match": {
"_id": "$$transcribeId",
"$text": {
"$search": "\"go away\""
}
}
}
]
}
}
])
上一个错误
{
"ok" : 0,
"errmsg" : "pipeline requires text score metadata, but there is no text score available",
"code" : 40218,
"codeName" : "Location40218"
}
我会试试这个,它在 4.4.1
对我来说运行良好。我只是重写了变量:
pipeline = [
{
"$lookup" : {
"from" : "meeting",
"let" : {
"meetingId" : "$meeting"
},
"as" : "meeting_data",
"pipeline" : [
{
"$match" : {
"$expr" : {
"$eq" : [
"$_id",
"$$meetingId"
]
}
},
"$text" : {
"$search" : "\"go away\""
}
}}]
}}]
db.getCollection('recording').aggregate(pipeline)
如果可行,下一阶段遵循相同的思路。