[DOCS-15298] [Server] Investigate changes in SERVER-65808: $search as subpipeline of $lookup with localField+foreignField is not supported Created: 29/Apr/22  Updated: 13/Nov/23  Resolved: 06/Jun/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 6.1.0-rc0, 6.0.0-rc4, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Minor - P4
Reporter: Backlog - Core Eng Program Management Team Assignee: Kanchana Sekhar
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-65808 $search as subpipeline of $lookup wit... Closed
is documented by DOCS-15300 [Atlas Search] Add $lookup and $union... Closed
Duplicate
is duplicated by DOCS-15301 [Atlas Search] Tutorial for $unionwit... Closed
Gantt End to End
has to be finished together with DOCS-15254 Investigate changes in SERVER-60800: ... Closed
Related
related to DOCS-15301 [Atlas Search] Tutorial for $unionwit... Closed
Participants:
Days since reply: 1 year, 36 weeks ago
Epic Link: DOCSP-22649

 Description   
Original Downstream Change Summary

This change allows usage of localField/foreignField in $lookup pipeline with $search

Description of Linked Ticket

A pipeline like this works as expected:

[{
  "$lookup": {
    "from": "suppliers",
    "let": { "s": "address.state" },
    "as": "details",
    "pipeline": [
      {
        "$search": {
          "text": {
            "query": "green",
            "path": "description"
          }
        }
      },
      { "$match": { "$expr": { "$eq": ["$$s", "$address.state"] } } }
    ]
  }
}
] 

But equivalent expressed with localField/foreignField produces an error.

 
db.test.aggregate([{ 
  "$lookup": { 
    "from": "suppliers", 
    "localField": "address.state", 
    "foreignField": "address.state", 
    "as": "details", 
    "pipeline": [ 
      { 
        "$search": { 
          "text": { 
            "query": "green", 
            "path": "description" 
          } 
        } 
      } 
    ] 
  } 
}]) 

"$_internalSearchMongotRemote is only valid as the first stage in a pipeline"

Scope of Changes

Spoke with kanchana.sekhar@mongodb.com on this. What we want to do on the server docs side is:

  • Mention this change in the release notes
  • Add a sub-section to the Examples section of $lookup called "$search Examples" and link out to the new tutorials being created in the Atlas Search docs.

Timing

Not required for World. The tutorials will be written post World.



 Comments   
Comment by Kanchana Sekhar [ 01/Jun/22 ]
Comment by Kanchana Sekhar [ 12/May/22 ]

jeffrey.allen@mongodb.com Slight change to what we discussed before: the tutorials will be available only after MDBW, but we have been requested to add a syntax example for $lookup and $unionWith in the docs for MDBW. So, I am considering using this ticket to add the syntax/usage examples. Your thoughts? Thanks!

Comment by Jeffrey Allen [ 02/May/22 ]

Moving to blocked until the new tutorials are created and we can link to them. kanchana.sekhar@mongodb.com please link the tutorial tickets to this one so we can see when we can start working on this ticket. Thanks!

Comment by Education Bot [ 29/Apr/22 ]

Fix Version updated for upstream SERVER-65808:
6.1.0-rc0, 6.0.0-rc4

Comment by Education Bot [ 29/Apr/22 ]

Fix Version updated for upstream SERVER-65808:
6.1.0-rc0

Generated at Thu Feb 08 08:12:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.