Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Has this Mongo Query to be really so slow?

I am struggling with a MongoDB query. The records' structure is really easy:

{ body: "Some sentence, no more than 4-5 lines I would say", title: "Just some characters", date: "2021-10-17 11:11:11" }

By now we have 800k records. When searching for uncommon words, the search is very very quick and results are given just after some ms, as expected. However, if using very common words, which may appear even in the most of records, the search itself can take up to 15 seconds.

The code I use is:

var queryString = "aVeryCommonWord";


db1.collection("nic_news").createIndex({
    title: "text",
    body: "text"
})

query = {
    $text: {
        $search: queryString
    },
    date: {
        $gt: "2021-10-17"
    } ,
 }

var skipInt = 0;

db1.collection("nic_news").find(query).skip(skipInt).sort({
    date: -1
}).limit(25).toArray(function (err, doc) {

...

Even if I limit the results by number and date, like in the code above, I got no less than 15 seconds to see results in console.

Any idea on how to optimize this search?

Thank you very much!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!