[SERVER-86281] $search with access to $$SEARCH_META followed by $lookup returns no results in 7.3.0-rc1 Created: 06/Feb/24  Updated: 07/Feb/24

Status: Needs Scheduling
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ann Wang Assignee: Charlie Swanson
Resolution: Unresolved Votes: 0
Labels: adf, search
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
is caused by SERVER-84202 Allow pushdown of all eligible SBE st... Closed
Related
is related to SERVER-86367 Revert changes in SERVER-84202 In Code Review
Operating System: ALL
Steps To Reproduce:

Populate db/coll:

 

db.search1.insertMany([{name: "apple jam"},{name:"strawberry jam"},{name: "apple blueberry jam"}])
db.search2.insertMany([{name: "blueberry jam"},{name:"strawberry jam"}])

 

Query:

 

db.search1.aggregate([{$search: {text:{path: "name", query: "apple"}}}, {$addFields: {score: {$meta: "searchScore"}, searchMeta: "$$SEARCH_META"}}, {$lookup: {from: "search2", localField: "name", foreignField: "name", as: "match"}}]) 
[
{     _id: ObjectId("65c169267ad0e23fd198464b"),     name: 'apple jam',     score:
{ meta: 'searchScore' }
,
    searchMeta: { count:
{ lowerBound: Long("2") }
},
    match: []
  },
 
{     _id: ObjectId("65c169267ad0e23fd198464d"),     name: 'apple blueberry jam',     score:
{ meta: 'searchScore' }
,
    searchMeta: { count:
{ lowerBound: Long("2") }
},
    match: []
  }
]
 

 

Even if the results from $lookup stored in the "match" field are empty, I still expect to see 2 documents returned as shown, but instead I'm seeing zero documents returned.

Participants:

 Description   

Using 7.3.0-rc1 caused an existing test to fail in ADFA that may indicate a bug with $$SEARCH_META used with $lookup.

I'm seeing no documents returned when querying using $search and accessing the $$SEARCH_META variable followed by a $lookup. The $search query itself should end up returning 3 documents, but when followed by a $lookup stage returns 0. I don't think this is expected behavior.

See steps to reproduce for a similar example.


Generated at Thu Feb 08 06:59:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.