Skip to content

Commit

Permalink
Merge pull request #160 from CSCfi/indexer-improvements
Browse files Browse the repository at this point in the history
Reduce indexing batch size. Specify retry count in NEST client
  • Loading branch information
sarkikos authored Nov 7, 2024
2 parents 4e2a499 + 8ee8f84 commit c0c589d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit c0c589d

Please sign in to comment.