[SERVER-61690] Adjust stored fields protocol for atlas search Created: 22/Nov/21  Updated: 29/Oct/23  Resolved: 01/Dec/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0, 5.1.2, 5.0.6, 4.4.11

Type: Task Priority: Major - P3
Reporter: Charlie Swanson Assignee: Ted Tuckman
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Duplicate
is duplicated by SERVER-61758 Adjust $search de-sugaring for stored... Closed
Related
related to SERVER-60809 Add ability to not idLookup after $se... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.1, v5.0, v4.4
Sprint: QO 2021-12-13
Participants:

 Description   

After going through syntax review, it was determined we'd name the stored fields under 'storedSource' rather than just 'stored', so we'll have to adjust the protocol accordingly.

It was also determined that _id could be excluded (optionally), so we should add some testing for that. I don't see anything in particular that will break based on my reading of the original patch for SERVER-60809.



 Comments   
Comment by Githook User [ 06/Dec/21 ]

Author:

{'name': 'Ted Tuckman', 'email': 'ted.tuckman@mongodb.com', 'username': 'TedTuckman'}

Message: SERVER-60809 Add 'returnStoredFields' argument to $search stage

SERVER-61690 Change protocol for getting stored fields from mongot

(cherry-picked from commit 2f83c0184dfc3dff1ef4cdba30d4629f29f28d5c)
Branch: v4.4
https://github.com/10gen/mongo-enterprise-modules/commit/0e1921cd128453e613cfe87f278307e41757eb93

Comment by Githook User [ 03/Dec/21 ]

Author:

{'name': 'Ted Tuckman', 'email': 'ted.tuckman@mongodb.com', 'username': 'TedTuckman'}

Message: SERVER-60809 Add 'returnStoredFields' argument to $search stage

SERVER-61690 Change protocol for getting stored fields from mongot

(cherry-picked from commit 304b5f763305d06b04b96e2bc782eecb073fb0a7)
Branch: v5.0
https://github.com/10gen/mongo-enterprise-modules/commit/2f83c0184dfc3dff1ef4cdba30d4629f29f28d5c

Comment by Githook User [ 03/Dec/21 ]

Author:

{'name': 'Ted Tuckman', 'email': 'ted.tuckman@mongodb.com', 'username': 'TedTuckman'}

Message: SERVER-60809 Add 'returnStoredFields' argument to $search stage

SERVER-61690 Change protocol for getting stored fields from mongot
Branch: v5.1
https://github.com/10gen/mongo-enterprise-modules/commit/304b5f763305d06b04b96e2bc782eecb073fb0a7

Comment by Githook User [ 01/Dec/21 ]

Author:

{'name': 'Ted Tuckman', 'email': 'ted.tuckman@mongodb.com', 'username': 'TedTuckman'}

Message: SERVER-61690 Change protocol for getting stored fields from mongot
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/4fbccf0697c729e6aa8ad27d594c91e4867f4103

Comment by Alexander Lukyanchikov [ 22/Nov/21 ]

To clarify, with this change logic on mongod side can be simplified. If returnStoredSource is set to true in the query, mongot will always return top-level "storedSource" field, but won't return top-level "_id". The expectation is that mongod would just return "storedSource" as is to the end user without any modifications. 

Note that "storedSource" might not contain _id and also can be empty.

A few examples for a query with returnStoredSource:true:

 

mongot output:
{
  "ok": 1,
  "cursor": {
    "id": {
      "$numberLong": "1235"
    },
    "ns": "rent.fairbnb",
    "nextBatch": [
      {
        "storedSource": {
          "_id": ObjectId("5099803df3f4948bd2f98391"),
          "location": "Holiday Inn"
        },
        "$searchScore": 3.22,
      }
    ]
  }
}
 
expected mongod output:
{
"_id": ObjectId("5099803df3f4948bd2f98391"),
 "location": "Holiday Inn"
}

 

 

mongot output:
{
  "ok": 1,
  "cursor": {
    "id": {
      "$numberLong": "1235"
    },
    "ns": "rent.fairbnb",
    "nextBatch": [
      {
        "storedSource": {
          "location": "Holiday Inn"
        },
        "$searchScore": 3.22,
      }
    ]
  }
}
 
expected mongod output:
{
 "location": "Holiday Inn"
}

 

mongot output:
{
  "ok": 1,
  "cursor": {
    "id": {
      "$numberLong": "1235"
    },
    "ns": "rent.fairbnb",
    "nextBatch": [
      {
        "storedSource": {
        },
        "$searchScore": 3.22,
      }
    ]
  }
}
 
expected mongod output:
{}

 

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