Questions tagged [nested-documents]

A data/object structure where documents are contained within other documents. Relates to indexing and used in search and database platforms and engines like mongodb, solr and elasticsearch

A data/object structure where documents are contained within other documents. Relates to indexing and used in search and database platforms and engines like mongodb, solr and elasticsearch

64 questions
6
votes
1 answer

Mongoose: CastError: Cast to embedded failed for value "{ value: 'x' }" at path "items"

After updating to Mongoose 5.11.13 I am getting the following error when trying to add an item to a sub-object inside a document. CastError: Cast to embedded failed for value "{ value: 'new item' }" at path "items" at model.Query.exec…
Edd Chang
  • 931
  • 1
  • 7
  • 16
4
votes
1 answer

How do I represent a Child Document in my Solr schema.xml?

I'm trying to achieve a document hierarchy like so, where the parent is the 'Bundle' and the children are 'Products': Bundle: id imageUrl Products: [ id:2 type:"t-shirt" sizes:[S,M,L] …
P_equals_NP_2021
  • 627
  • 1
  • 9
  • 27
3
votes
1 answer

Merge two objects inside an array, one with a key nested deeper than the other in the same document in Mongo DB

Schema of the document id is the key to join { "foo" : [ { "properties" : { "id" : 1 }, }, { "properties" : { "id" : 2 }, }], …
3
votes
1 answer

query and project a nested array using the c# Mongodb driver

Hi I am trying to learn how to use mongoDb with the c# driver. I have a collection similar to this: public class DataSnapshot { [BsonId] public ObjectId InternalId { get; set; } public Int Id { get; set; } public string Identifier1…
Paul
  • 693
  • 1
  • 10
  • 25
3
votes
1 answer

Access dynamic nested key in JS object

I have an array like ['animals', 'cats', 'cute', 'fast', 'small', ...], and want to access nested keys of the object like let object = { one: { two: { three: { // and so on } } } } Usually I would write…
Max Mikhalchuk
  • 85
  • 1
  • 2
  • 11
2
votes
2 answers

Mongo Shell update nested array of documents

I try to set an attribute of an document inside an array to uppercase. Here is the link to the mongodb playground https://mongoplayground.net/p/BTP_h3kqK_S this is a document example { "_id": ObjectId("5e786a078bc3b3333627341e"), "value":…
Dimi
  • 23
  • 5
2
votes
0 answers

SOLR: eDisMax with nested documents

We do have an index of e-books that contains the metadata of the e-book and each page as a single document: Book 1 Page 1 Page 2 Page 3 ... Page n The parent document contain a field is_parent:true, an id and doc_id. For parent documents, the…
Gesh
  • 565
  • 1
  • 6
  • 21
2
votes
2 answers

Updating a double nested array MongoDB

Consider this schema: let userSchema = new mongoose.Schema({ id: String, displayName: String, displayImage: String, posts: [ { url: String, description: String, likes: [String], comments: [ { content:…
JohnSnow
  • 6,911
  • 8
  • 23
  • 44
2
votes
1 answer

MongoDB query nested document fields simultaneously

Having document in collection test as follow: {a:2, list:[{lang:"en", value:"Mother"}, {lang:"de", value:"Mutter"}] } When I query: db.test.find({"list.lang":"de", "list.value": "Mother" }) I'm expecting to get nothing, but on reason that exist…
Dewfy
  • 23,277
  • 13
  • 73
  • 121
1
vote
1 answer

MongoDB Aggregate two collections and flatten the second collection

Collection - 1 (users) { "_id" : "aandtv10@gmail.com", "updateTimestamp" : "2022-07-19T11:59:18.029Z", "userConsent" : null, "firstName" : "Aand", "lastName" : "Aa", "fullName" : "Aand Aa", "orgRootName" :…
mperle
  • 3,342
  • 8
  • 20
  • 34
1
vote
1 answer

PyMongo - Update the field for the object in nested array

Trying to update the nested object for the document in MongoDB. { "items" : [ { "id": 1, "name": "a", "child": [ { "id": 11, "name": "aa" }, { "id": 12, "name": "bb" }, ] }, …
1
vote
1 answer

What is the best method to run several compuations on a large dataset with one time reading?

I am processing a very big dataset which includes 200 of compressed JSON files (each ~ 8G uncompressed) in Spark. I have created a main dataframe largeDF, and several additional dataframes to compute aggregates on nested attributes (which are arrays…
PyGuy
  • 434
  • 5
  • 15
1
vote
1 answer

MongoDB querying nested documents

I have records like: { "_id" : ObjectId("5f99cede36fd08653a3d4e92"), "accessions" : { "sample_accessions" : { "5f99ce9636fd08653a3d4e86" : { "biosampleAccession" : "SAMEA7494329", …
shaw2thefloor
  • 600
  • 5
  • 20
1
vote
1 answer

MongoDB: finding matched elements in the third level embed documents

I am new to MongoDB. I have a typical use case. Here is my single document JSON structure. { "category":"cat_1", "_id": "id1", "levels":[ { "id":"l1", "orders":[ { …
Smith Dwayne
  • 2,675
  • 8
  • 46
  • 75
1
vote
2 answers

Solr Nested Document w/ Field Labelled Relationship: Single Elements Not Stored In Arrays

While indexing my data, I found that some nested documents are not stored correctly. I run Solr 8.3 and make use of the labelled relations as described in the docs. Data Whenever a root entity, Parent, has any amount of Child entities, I generate…
Barthy
  • 3,151
  • 1
  • 25
  • 42
1
2 3 4 5