Questions tagged [graphlookup]

MongoDB aggregation operator, Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.

Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.

32 questions
0
votes
0 answers

Hierarchical queries with Mongo and NodeJS

I have a collection of Categories where a single category can have multiple parents categories or null in case of root category. The schema is as follows: const categorySchema = mongoose.Schema({ CategoryName: [{ type: String, …
0
votes
1 answer

MongoDB Graph: Find A and B where A->B exists but B->A doesn't

I need to find a query where the statement in the title holds true with the training_sample db of mongodb. This is the data structure (directional graph): { _id: ObjectId("56e9b39c732b6122f878f882"), airline: { id: 3778, name: 'Oman Air',…
Fenrir
  • 231
  • 2
  • 18
0
votes
0 answers

How to use the result of $graphLookup in $match stage

I have two collections with the following schema: product_categories interface Category { _id: string; name: string; parentId: string; } This collection is hierarchical. Example…
h-sifat
  • 1,455
  • 3
  • 19
0
votes
0 answers

MongoDB $graphlookup to link Twitter user account names with user mentions

A sample document with user mentions in the tweets dataset I'm working with looks like this. I'm trying to get mongoDB to link the user.screen_name with their mentions in other tweets, if there are any, and go further up the hierarchy if that tweet…
cooperano
  • 23
  • 4
0
votes
0 answers

MongoDB $graphLookup to find nested tweets hierarchy?

I'm practicing mongoDB with a small tweets dataset right now and don't have much experience with $graphLookup. For each document that matches, I'm trying to find the screen_name of the user the tweet is replying to, and if that tweet is also a…
cooperano
  • 23
  • 4
0
votes
0 answers

MongoDB $graphLookup omits repeat records

I have collection in which I have defined all my products and their sub-products. The sub-products are not defined as sub-documents but as a separate document in the collection. const productTypeSchema = mongoose.Schema({ name: { type: String,…
Mahesh
  • 1
  • 3
0
votes
1 answer

How to $graphLookup with dynamic parent references in Mongoose

Let's assume I'm making a react app to manage what's in my restaurant's fridge. I have three collections: Refrigerators (contains jars or food items) Jars (contains jars or food items; exists in refrigerators or other jars) Food Items (exists in…
0
votes
1 answer

How to recursively query the nested documents of mogodb?

{ "id": "1505036191456227329", "materialList": [ { "id": "1505035441229459457", "model": "", "parentId": "0", }, { "id": "1505035441229459458", …
tengger
  • 1
  • 1
0
votes
1 answer

How to get all children documents using $graphLookup of MongoDB

I have this data as below in two collections of MongoDB. categories: [ { "_id" : 1, "name" : "A" }, { "_id" : 2, "name" : "B", "categoryId" : 1 }, { "_id" : 3, "name" : "C", "categoryId" : 1 }, { "_id" : 4, "name" : "D", "categoryId" : 2 }, …
Sara
  • 5
  • 3
0
votes
1 answer

Invalid hlookup result if range lookup true

I've problem with Microsoft Excel HLOOKUP function as below As you can see, the result is #N/A for function that set true as lookup range Where I'm expecting is should be 25 since it should find Mangga correctly (Like when it's false) But searching…
0
votes
1 answer

graphlookup in mongodb - query

I have a data set db.users.insertMany([ {"_id":1, "name":"abcd" }, {"_id":2, "name":"abcd"}, {"_id":3, "name":"abcd" }, {"_id":4, "name":"abcd"}, {"_id":5, "name":"abcd" }, {"_id":6, "name":"abcd"}, {"_id":7, "name":"abcd" }, {"_id":8,…
Wajih
  • 93
  • 1
  • 10
0
votes
1 answer

Join $graphLookup result with other collection

I'm working on a hierarchical structure that stores a binary tree. Let's say I have two collections: users and nodes. users collection stores personal information and nodes stores the structure of the tree using the Parent References pattern:…
0
votes
1 answer

Mongodb graphLookup cond into connectToField

Its posible add $cond into $connectToField example { $graphLookup: { from: 'samecollection', startWith: '$myid', connectFromField: 'myid', connectToField: { $cond: { true , 'myidsRelated.id', 'newRelated.id'} }, as: 'elements', }, },
Jonathan
  • 41
  • 7
0
votes
1 answer

MongoDB: how to get the count of all the child nodes recursively with the condition?

How to get the count of all the child nodes recursively with the condition? I have the structure of a collection like this: | id | parentID | type | ----------------------------- | 1 | NULL | A | ----------------------------- | 2 …
Prakash Naidu
  • 742
  • 2
  • 7
  • 17
0
votes
1 answer

How to use graphLookup query of MongoDB to answer the question : Give me all persons connected to “X” through hotels

My documents look as below : { _id: 1, personId: 'Sai', pnr: "P1", flight: 'F1', hotel: 'H1' }, { _id: 2, personId: 'Sai', pnr: "P2", flight: 'F2', hotel: 'H2' }, { _id: 3, personId: 'Sai', pnr: "P3", flight: 'F3', hotel: 'H3' }, { _id: 4,…