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

183
Visualizações
Creating a sample of huge collection in mongodb to test queries

I have a huge collection of tweets downloaded by someone else and I want to test an aggregate() query on that. But, it takes a lot of time to execute and I want to quickly check my results.

Can I create a smaller sample collection using the huge original collection so that I can test new queries on that quickly? If yes, how can I do that? If no, how do people usually test the correctness of the query before execution?

All the answers I found till now say about dumping the entire collection while I just want a sample of it to run my aggregate() query. I've tried doing a db.collection.findOne().aggregate(/*QUERY*/) but it throws an error saying that aggregate is not a function

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

you can easily create a subset of your collection like this :

db.collection.aggregate({$limit: 1000}, {$out: "subsetCollection"})

this will take 1000 results from yout original collection and write the to a new collection named "subsetCollection". You can then test your aggregation queries on this new collection

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