0

Good morning colleagues,

I want to make a query regarding how it would be formulated and what would be recommended and the most optimal for making queries with a large number of elements.

I have an api using express that creates a new mongodb model with a unique name and then includes elements inside.

Example:

Collections

*product234 => includes elements => { _:id: ...., name: ... }, { ...}

*product512 => includes elements => { _:id: ...., name: ... }, { ...}

Each collection hosts more than 5000 elements and I want to create a search engine that returns all the results of all the collections that match the "name" that I will send in the request.

How could I perform this query using mongoose? Would it be viable and would it not bring me performance problems by having more than 200 collections and more than 5000 elements in each one?

Answer (Edit):

As i see in the comments the best solution for this for making fast queries is to create a copy of the element with only name or needed values, reference id and reference collection name into a new collection named for example "ForSearchUse" and then make the query to that collection, if complete info is needed then you can query it to the specific collection using the reference id and name of the element

JDLR
  • 520
  • 1
  • 4
  • 20

0 Answers0