Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 Respostas
Responde à pergunta

0

You can use $regex operator:

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

Working example

over 4 years ago · Santiago Trujillo Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda