He notado que mi API es lenta. Volver a restaurantes cuando se busca en ciudades es de alrededor de 4 segundos en promedio (incluso si solo hay 10 resultados). La misma búsqueda (sin RegExp), directa en Mongo Atlas es una décima de segundo. Aquí está mi código javascript. Estoy usando Express, Mongoose y RegExp en mi js. ¿Hay alguna forma de acelerar esto, por favor? :
// Route to return all restaurants matching the searched name, returning all fields, using a collection that has collation// app.route("/restaurants/:restaurantName") .get(function(req, res) { let partialToMatch = new RegExp(req.params.restaurantName, 'i'); Restaurant.find({ BusinessName: partialToMatch }, null, { limit: 25 }, function(err, foundRestaurant) { if (foundRestaurant) { res.send(foundRestaurant) } else { res.send("No restaurants matching that title was found."); } }); });