Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
Mongoose indexing html text?

I have a doc with field html. The html field stores real html.

schema: {
  html: String
}
doc: {
  "html" : "<p>I am html<p>"
}

And I want to index the html field that when I search "I am html" it should return that doc.

Is there any way to search that document only using text inside of that html tag.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can use $regex operator:

db.collection.find({
  "html": {
    "$regex": "I am HTML"
  }
})

Working example

over 4 years ago · Santiago Trujillo Denunciar

0

If you have text index on this collection, you can search as:

db.collection.find({
  $text: {
    $search: "\"I am html\""
  }
})

With double-quotes wrapped, you can search as exact phrase.

You can also search for exact phrases by wrapping them in double-quotes. If the $search string includes a phrase and individual terms, text search will only match documents that include the phrase.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda