MongoDB Charts error loading data source fields

Hi we have restructured our data. Now when I want to open my data source on charts it gives me the following error “there was an error when loading the data source fields”. The collection shows up on compass and i can query it in the shell. The collection currently contains 510 fields , is there a maximum amount that can be pulled into charts? Attached is a screenshot.mongo.
Too add to this my collection size is 36MB , is there a limit on what collection sizes can be?And is the limit only for mongo charts?

Hi @johan_potgieter -

There shouldn’t be any practical limit on the number of fields we show in the field panel. Also 36MB is not a large collection. For very large collections there can be a risk of timeouts when getting the data for the chart, but the field sample runs on a small number of documents so it should always work.

Unfortunately there’s a bug in the current version of Charts where we don’t show the error message when the field sampling fails. This makes it hard to diagnose. We’ll have a new release out next week which fixes this, but in the meantime you can find the error if you open your browser’s dev tools and use the Network tab. You should see a red “call” entry with the error message in the response body. Let me know if you’re able to find this or if you need further help.


Thanks @tomhollander. I ran it again now and attached is the error message i get.

Through some trial and error it seems to me that the error occurs when i reach close to a 1000 fields in a collection. Although further experimentation is required. Any advise will be appreciated.

Can you click the red call entry and see the details of the response?

Sure attached is screenshot of all the info.

Second Part.

Third Part.

Sorry can you click the Response tab? That’s where the error message will be.

And sorry then another question. Is there a way to subtract 2 arrays that are the same length from one another and produce the value in another array?

Ah I found it. Here is the error.
{“error”:"(Location16820) Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.",“error_code”:“MongoDBError”,“link”:“”}

Hi @johan_potgieter -

Regarding your array question, assuming the two arrays you want to subtract from each other are in different fields in the same document, you could use the following approach:

chartsMonoRepl:PRIMARY> db.arraydiff.find()
{ "_id" : ObjectId("5eefd7841994dbe8050da7b8"), "a" : [ 10, 20, 30, 40, 50 ], "b" : [ 1, 2, 3, 4, 5 ] }
chartsMonoRepl:PRIMARY> db.arraydiff.aggregate([
...     {
...         $addFields: {
...             diff: {
...                 $map: {
...                     input: {
...                         $zip: {inputs: ["$a", "$b"]}
...                     },
...                     as: "el",
...                     in: {
...                         $subtract: [
...                             {$arrayElemAt: ["$$el", 0]},
...                             {$arrayElemAt: ["$$el", 1]}
...                         ]
...                     }
...                 }
...             }
...         }
...     }
... ]);
{ "_id" : ObjectId("5eefd7841994dbe8050da7b8"), "a" : [ 10, 20, 30, 40, 50 ], "b" : [ 1, 2, 3, 4, 5 ], "diff" : [ 9, 18, 27, 36, 45 ] }

Thanks for sending the full error message for your other problem. I’m still looking into why this is happening, but as you suggested it may be to do with having such a large number of fields. I’ll let you know when I have any further info on this.


Great i will give it a try. Thanks for the support Tom.

Works perfectly. Thanks so much.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.