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

48 questions
5
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
  • 673
  • 1
  • 4
  • 14
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
  • 497
  • 4
  • 18
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
  • 3
2
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 }, }], …
2
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
  • 495
  • 7
  • 20
2
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…
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
  • 507
  • 5
  • 20
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
  • 4,775
  • 7
  • 16
  • 37
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
  • 21,895
  • 12
  • 66
  • 114
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
  • 281
  • 3
  • 12
1
vote
1 answer

MongoDB querying nested documents

I have records like: { "_id" : ObjectId("5f99cede36fd08653a3d4e92"), "accessions" : { "sample_accessions" : { "5f99ce9636fd08653a3d4e86" : { "biosampleAccession" : "SAMEA7494329", …
shaw2thefloor
  • 590
  • 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
  • 1,977
  • 7
  • 30
  • 58
1
vote
1 answer

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
  • 2,624
  • 1
  • 16
  • 37
1
vote
1 answer

Accessing nested documents within nested documents

I'm having a problem that is really bugging me. I don't even want to use this solution I don't think but I want to know if there is one. I was creating a comment section with mongodb and mongoose and keeping the comments attached to the resource…
Stephen Agwu
  • 883
  • 1
  • 12
  • 24
1
vote
1 answer

How to sum the value of child documents in a specific matching search criteria using solr?

I have the following indexed documents { "id":"data1", "isParent":"1", "_childDocuments":[ { "description":"Benefit and Payroll consultant with HR team ", "isParent":"2", "exp":2 }, …
1
2 3 4