Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce indexing batch size. Specify retry count in NEST client #160

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aspnetcore/src/ElasticService/ElasticSearchExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ private static ConnectionSettings GetConnectionSettings(IConfiguration configura
{
var elasticSearchClusterUrl = configuration["ElasticSearch:Url"] ?? throw new InvalidOperationException("ElasticSearch url missing.");

// https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/configuration-options.html
var connectionSettings = new ConnectionSettings(new Uri(elasticSearchClusterUrl))
.DefaultFieldNameInferrer(i => i); // This forces elastic to store .Net objects using type names, instead of camel casing. This enables using nameof when referring to fields.
.DefaultFieldNameInferrer(i => i) // This forces elastic to store .Net objects using type names, instead of camel casing. This enables using nameof when referring to fields.
.MaximumRetries(5);

if (Debugger.IsAttached)
{
Expand Down
2 changes: 1 addition & 1 deletion aspnetcore/src/ElasticService/ElasticSearchIndexService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ElasticSearchIndexService : IElasticSearchIndexService
private readonly IElasticClient _elasticClient;
private readonly ILogger<ElasticSearchIndexService> _logger;

private const int BatchSize = 2000;
private const int BatchSize = 1500;

public ElasticSearchIndexService(IElasticClient elasticClient, ILogger<ElasticSearchIndexService> logger)
{
Expand Down
2 changes: 1 addition & 1 deletion aspnetcore/src/Indexer/Indexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private async Task IndexEntities(string indexName, IIndexRepository repository,
*/

int skipAmount = 0;
int takeAmount = 50000;
int takeAmount = 30000;
int numOfResults = 0;
int processedCount = 0;

Expand Down
Loading