Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created June 19, 2015 13:32
Show Gist options
  • Save rodolfofadino/97056ec609ada716fbc8 to your computer and use it in GitHub Desktop.
Save rodolfofadino/97056ec609ada716fbc8 to your computer and use it in GitHub Desktop.
Update SOLR Document c#
private static void ExportClientesToSolr(List<Cliente> listaDeClientes)
{
Startup.Init<Cliente>("http://solr-server:8080/solr/solrcluster/");
ISolrOperations<Cliente> solr = ServiceLocator.Current.GetInstance<ISolrOperations<Cliente>>();
var total = listaDeClientes.Count();
var indice = 0;
foreach (var cliente in listaDeClientes)
{
indice++;
Console.WriteLine(((((decimal)indice / (decimal)total) * (decimal)100)).ToString("N2") + " %");
solr.Add(new Cliente() { Id = cliente.Id, Nome = cliente.Nome });
//solr.Commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment