[SERVER-38124] executing the expression in a field Created: 14/Nov/18  Updated: 06/Dec/22  Resolved: 15/Nov/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: naresh buruzula Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-30417 add expression to get value by keynam... Closed
Assigned Teams:
Query
Operating System: ALL
Steps To Reproduce:

db.submissions.aggregate([
    { $addFields: { 
          "ftpath": {
              $let: {
                 vars: {
                    "identifier": \{$ifNull: ["$requests.Certification.identifiers.Certification.id", ""]},
 },
                  in: \{$concat: [{ $literal: "$outputs." }, "$$identifier", ".response.value.FileType"]}
 }
 },
 "ftval": // I want to evaluate 'ftpath' which has "$outputs.123456.response.value.FileType" init. assign the value to ftval
 } 
 }
])

Participants:

 Description   

I want to use a field which has expression within it.

like ftpath = "$outputs.123456.response.value.FileType"

I want execute the value inside $ftpath.



 Comments   
Comment by naresh buruzula [ 15/Nov/18 ]

db.submissions.aggregate([
{ $match : { "requests.Certification" :

{"$exists":true}

} },
{ $addFields: {
   "ftpath": {
      $let: {
         vars: {
            "path": {$concat: [

{ $literal: "$outputs." }

, "1234"]}}, // here "path" will be assigned with $outputs.1234
            in: "$$path"
            // $$path will give "$outputs.1234". Can i not execute "$outputs.value" and return the value inside "$outputs.1234"
            }
        }
     }
   }
])

Comment by naresh buruzula [ 15/Nov/18 ]

"outputs" : {"1234" : "actual value"}
identifiers: {"abc": "1234"}
}

I want to get the identifier (1234) of "abc" from "identifiers".
Use that identifier(1234) and fetch the value from "outputs"

Comment by Danny Hatcher (Inactive) [ 15/Nov/18 ]

Closing as a dupe of SERVER-30417.

Comment by Asya Kamsky [ 14/Nov/18 ]

daniel.hatcher is this a duplicate of SERVER-30417 - looks like it is to me.

Generated at Thu Feb 08 04:48:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.