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

72
Visualizações
Mongo DB search by condition priority

I am performing a search on the collection based on different columns. Basically what I need is that when I search, the name starting with the keyword entered should appear on top of the list, and then other names from different columns that contain the keyword should appear.

I am having a hard time finding direct functionality in MongoDB to perform this operation. Any logic is appreciated.

example :

[
  { name : Pro1},
  { name : testpro},
  { name : Pro2},
  { name : testpro2}
]


so when I query on this array with the keyword **Pro** the expected output should be :

[ Pro1,Pro2,testpro,testpro2]


so that all the names starting with the exact keyword should appear first then the list of names containing the keyword should be there.
about 4 years ago · Juan Pablo Isaza
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