[SERVER-37586] Documentation is not sufficient Created: 12/Oct/18  Updated: 13/Oct/18  Resolved: 13/Oct/18

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

Type: Bug Priority: Major - P3
Reporter: Kumar Muthaiah Assignee: Ramon Fernandez Marina
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Are you guys running for money? Just omitting more example scenarios for aggregation framework? You documentation is incomplete making users to beg for solutions in other places! If you do some work do it fully or why waste our time? Can you feel the responsibility yourself? Do you feel humans or you feel business? Money or humans?

I don't find example for following collection scenario using lookup and aggregation.

Many companies focussing on source code rather than documentation which is actually needed to add more customers. If I'm frustrated with help then I will go for a tool where documentation is fully available.

Just giving new tools to humans Is not enough. How you help them later matters.

If you really feel your responsibility, then add several examples to cover all possible scenarios in the documentation.

 
a { id: objectId of b }

b { id: objectId of c }

c { id: objectId in an array pointing to d, id: objectId in an array pointing to e, id: objectId in an array pointing to f }

d { }

e { }

f { }
 



 Comments   
Comment by Ramon Fernandez Marina [ 13/Oct/18 ]

Hi kumar.muthaiah@yahoo.com, there's a lot of information here so I'll do my best to cover it all.

First of all, whenever you need assistance it helps to follow these guidelines:

  • Try to create an example that others can understand and follow. A good example is the description of SERVER-22881, where there's a small dataset and an expected output – please try to follow that model in the future.
  • Create a script that generates your sample dataset; that should help others help you faster
  • Explain what you've already tried, and how has it failed to produce the expected results

In other words: help others help you.

Second, in your first comment in this ticket you mention this post. That turned into a feature request in SERVER-22881 which has seen been implemented and released. While it is true that the documentation for that feature is still in the pipeline (DOCS-8930), you absolutely don't need it.

I spent some time trying to understand what you're trying to do. First I wrote a script to create your dataset, since you didn't provide that:

db.data.drop()
db.data.insert({
    "_id" : ObjectId("5bc04c52db3b4b4c1ae4e6e1"),
    "aId" : ObjectId("5bc04c52db3b4b4c11e4e6e1"),
    "bId" : ObjectId("5bc04c52db3b4b4c13e4e6e1"),
    "cId" : ObjectId("5bc04c52db3b4b4c19e4e6e1")
})
 
db.c.drop()
db.c.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c19e4e6e1"),
    "name" : "",
    "description": "",
    "dId" : ObjectId("5bc04c52db3b4b4c14e4e6e1"),
    "eId" : ObjectId("5bc04c52db3b4b4c16e4e6e1"),
    "fId" : ObjectId("5bc04c52db3b4b4c18e4e6e1")
})
 
db.e.drop()
db.e.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c16e4e6e1"),
    "gId" : [
        ObjectId("5bc04c52db3b4b4c15e4e6e1")
    ],
    "hId" : [ObjectId("5bc04c52db3b4b4c15e4e6e2")],
    "iId" : [ObjectId("5bc04c52db3b4b4c15e4e6e3")]
})
 
 
db.g.drop()
db.g.insert({
    "_id" : ObjectId("5bc04c52db3b4b4c15e4e6e1"),
    "name" : "n1",
    "description" : "d1"
})
 
db.h.drop()
db.h.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c15e4e6e2"),
    "name" : "n2",
    "description" : "d2"
})
 
db.i.drop();
db.i.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c15e4e6e3"),
    "name" : "n2",
    "description" : "d2"
})
 
 
db.a.drop()
db.a.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c11e4e6e1"),
    "name" : "n2",
    "description" : "d2"
})
 
db.b.drop()
db.b.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c13e4e6e1"),
    "name" : "n2",
    "description" : "d2"
})
 
db.d.drop()
db.d.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c14e4e6e1"),
    "name" : "n2",
    "description" : "d2"
})
 
db.f.drop()
db.f.insert(
{
    "_id" : ObjectId("5bc04c52db3b4b4c18e4e6e1"),
    "name" : "n2",
    "description" : "d2"
})

Then I looked at the the existing documentation for $lookup and tried to assemble all the data for the only document in the data collection; I didn't go through it all, but here's some sample code that should give you an idea of how to manipulate your dataset to get what you want:

db.data.aggregate([
  {$lookup: { from: "a", localField: "aId", foreignField:"_id", as:"data_a"}},
  {$lookup: { from: "b", localField: "bId", foreignField:"_id", as:"data_b"}},
  {$lookup: { from: "c", localField: "cId", foreignField:"_id", as:"data_c"}},
  {$lookup: { from: "d", localField: "data_c.dId", foreignField:"_id", as:"data_d"}},
  {$lookup: { from: "e", localField: "data_c.eId", foreignField:"_id", as:"data_e"}},
  {$lookup: { from: "f", localField: "data_c.fId", foreignField:"_id", as:"data_f"}},
  {$lookup: { from: "g", localField: "data_e.gId", foreignField:"_id", as:"data_g"}}
]).pretty()

This produces the following output:

{
        "_id" : ObjectId("5bc04c52db3b4b4c1ae4e6e1"),
        "aId" : ObjectId("5bc04c52db3b4b4c11e4e6e1"),
        "bId" : ObjectId("5bc04c52db3b4b4c13e4e6e1"),
        "cId" : ObjectId("5bc04c52db3b4b4c19e4e6e1"),
        "data_a" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c11e4e6e1"),
                        "name" : "n2",
                        "description" : "d2"
                }
        ],
        "data_b" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c13e4e6e1"),
                        "name" : "n2",
                        "description" : "d2"
                }
        ],
        "data_c" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c19e4e6e1"),
                        "name" : "",
                        "description" : "",
                        "dId" : ObjectId("5bc04c52db3b4b4c14e4e6e1"),
                        "eId" : ObjectId("5bc04c52db3b4b4c16e4e6e1"),
                        "fId" : ObjectId("5bc04c52db3b4b4c18e4e6e1")
                }
        ],
        "data_d" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c14e4e6e1"),
                        "name" : "n2",
                        "description" : "d2"
                }
        ],
        "data_e" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c16e4e6e1"),
                        "gId" : [
                                ObjectId("5bc04c52db3b4b4c15e4e6e1")
                        ],
                        "hId" : [
                                ObjectId("5bc04c52db3b4b4c15e4e6e2")
                        ],
                        "iId" : [
                                ObjectId("5bc04c52db3b4b4c15e4e6e3")
                        ]
                }
        ],
        "data_f" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c18e4e6e1"),
                        "name" : "n2",
                        "description" : "d2"
                }
        ],
        "data_g" : [
                {
                        "_id" : ObjectId("5bc04c52db3b4b4c15e4e6e1"),
                        "name" : "n1",
                        "description" : "d1"
                }
        ]
}

This being said, I believe this schema will give you a lot of headaches in terms of maintenance, and I urge you to consider a different schema that helps you take advantage of the document model; there's plenty of documentation out there, both in the MongoDB website and the Internet, but here are some pointers to get started:

Finally, please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion, posting on the mongodb-user group or Stack Overflow with the mongodb tag as you did is the way to go. See also our Technical Support page if you need professional support.

Regards,
Ramón.

Comment by Kumar Muthaiah [ 13/Oct/18 ]

You are not trying to reply even single word. How bad you guys are? Selfish peoples!

Comment by Kumar Muthaiah [ 13/Oct/18 ]

Do you know one thing, why innovation in this world is very slow? It is because of you guys wasting others precious time. You guys only live for money. We don't live for money, but for benefit of humanity. You know all peoples will one day realise that money doesn't matter but LOVE matters.

Comment by Kumar Muthaiah [ 13/Oct/18 ]

See the stack over flow blog as below, I've asked there, since you don't respond. Live happily by not answering to customers. You will not be always the leader in database, and somebody will come in future, with better documentation and other features. Ego is bad.

https://stackoverflow.com/questions/52790332/lookup-query-nested-and-with-arrays-in-mongodb

Comment by Kumar Muthaiah [ 13/Oct/18 ]

Your query language is difficult to understand. Can you guys provide some tools to handle this? Felt there is a relief from SQL, but now another complexity in understanding MongoDB query language.

Comment by Kumar Muthaiah [ 13/Oct/18 ]

This much time to get the answer for my questions?  You can send email for answers to my questions and simultaneously solve documentation issues if you are taking actions on that.

Comment by Kumar Muthaiah [ 12/Oct/18 ]

Do you know how many bad designs in software are due to bad documentation and improper guidance from a junk guides in a software blog (like stack overflow). Also junk number of users commenting without knowing what it is? The user choses one user solution in a software blog and goes with bad design. The owner (mongodb) as the responsibility and not others like stack overflow, etc.,  

Are you allowing stack overflow to become famous by omitting documentation so that users will give business for stack overflow? So everybody will look into their business we user as to beg since we are not richer than you?

Comment by Kumar Muthaiah [ 12/Oct/18 ]

If you really feel it stop enhancing mongo db and concentrate on documentation first. Then do new features.

Comment by Kumar Muthaiah [ 12/Oct/18 ]

If nothing works I will move to MySQL. No need NO SQL, without sufficient documentation. No need to buy MongoDB cloud storage. Better stick with mysql provided by cloud provider.

Comment by Kumar Muthaiah [ 12/Oct/18 ]

I need to combine all the collections mentioned and put it in single json without losing hierarchy

Comment by Kumar Muthaiah [ 12/Oct/18 ]

Your incomplete documentation:

 

https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/

Comment by Kumar Muthaiah [ 12/Oct/18 ]

See I'm begging Stack Overflow for solution. Do you guys think the customers as cheap people once you get famous?

user: Kumar:

https://stackoverflow.com/questions/34967482/lookup-on-objectids-in-an-array/52776796#52776796

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