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

293
Views
How can I search for specific words in mongodb using mongoose

I have a collection that contains two documents: name content

the content contains long texts and what I want to do is I want to search for a specific word in my documents (just inside the content field) and get its name and index.

For example:

id:619c10
name: papers
content: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore 


id:619c20
name: Stone
content: stie nunc non blandit massa. **Neque** egestas congue quisque egestas diam in arcu cursus. Commodo ullamcorper a lacus vestibulum. Arcu odio ut sem nulla pharetra diam. Commodo viverra maecenas

For example, the word I'm looking for is "Neque" which is in the second document. I want to get this: name Stone Index: 27

I used regex but I don't know what should I do with the response to get name and index.

Subtitle.find({ content: { $regex: 'Neque', $options: 'i' } }, (error, data) => {
  if (error) {
    console.log(error);
  } else {
    console.log(data);
  }
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You will have to index the content field to be able to perform search queries , read this : https://docs.mongodb.com/manual/text-search/#:~:text=MongoDB%20supports%20query%20operations%20that,index%20and%20the%20%24text%20operator.&text=Views%20do%20not%20support%20text%20search.

about 4 years ago · Juan Pablo Isaza 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!