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

359
Visualizações
How to use the NEST ".net client" for Elasticsearch to paginate through all the records?

I am trying to use the C# .net client for Elasticsearch NEST to paginate through all the available records.

I want to get a list of all ids from the server 5000 at a time. So the very first request I get 0-5000, next request 5001-10000, then 10001-15000....

It seems that I should be using the search_after API to get the records but puzzled on how to retrieve the data.

Here is what I tried to do, but I feel that I am not understanding what I am doing and how can I make multiple requests..

var products = await elasticClient.SearchAsync<Product>(x =>  
    x.Source(s => s.Includes(se => se.Field(sef => sef.Id))) // all I need back is the "id" field
     .Sort(srt => srt.Ascending(p => p.Id)) // we can sort the ids
     .SearchAfter(5000, "get list of ids??"); // I have no idea what parameters to provide this method!
);

How can I use the .net library to loop over all available ids "5000" ids at a time?

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

0

Try this with pageNumber param:

var products = await elasticClient.SearchAsync<Product>(x =>  
    x.Source(s => s.Includes(se => se.Field(sef => sef.Id)))
    .From(5000*(pageNumber-1))
    .Size(5000)
    .Sort(srt => srt.Ascending(p => p.Id))
);
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