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

394
Views
Why I cannot do sort operation in Mongodb3.4 text search

I followed the guide in the page mongo Text Search but when I build text index on my collection (about 2 million lines) and try to search some and sort by score, it returns an error:

Error: error: {
    "ok" : 0,
    "errmsg" : "Executor error during find command: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.",
    "code" : 96,
    "codeName" : "OperationFailed"
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

According to the docs, if mongoDB can't obtain the sort order via an index scan it will use an algorithm that will buffers the first k results of the query. If the memory footprint exceeds 32 megabytes, the query will fail which is what you are experiencing. Try to limit the number of scanned results by using the limit() method.

over 4 years ago · Santiago Trujillo Report

0

@Tristan is correct but a better solution than using limit would be to filter by the score first. By using limit you may not get the highest score in your record set.

As an example if your score was out of 100 and you were interested in high scores filter on that first before the performing the sort.

db.getCollection("myCollection").find(
  { 
    "score" : {
      "$gt" : 90
    }
  }
).sort(
  { 
    "score" : 1.0
  }
);
over 4 years ago · Santiago Trujillo Report
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!