From fe8e4d3810dd8229eb880f047f47602d8f5456db Mon Sep 17 00:00:00 2001 From: Koen Metsu Date: Wed, 20 Nov 2024 15:14:12 +0100 Subject: [PATCH] fix: or-2558 check if locatie is already present when appending --- .../Projections/Search/ElasticRepository.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AssociationRegistry.Admin.ProjectionHost/Projections/Search/ElasticRepository.cs b/src/AssociationRegistry.Admin.ProjectionHost/Projections/Search/ElasticRepository.cs index d5f730b84..ff4330b71 100644 --- a/src/AssociationRegistry.Admin.ProjectionHost/Projections/Search/ElasticRepository.cs +++ b/src/AssociationRegistry.Admin.ProjectionHost/Projections/Search/ElasticRepository.cs @@ -81,7 +81,9 @@ public async Task AppendLocatie(string id, ILocatie locatie) where T : class id, selector: u => u.Script( s => s - .Source("ctx._source.locaties.add(params.item)") + .Source("if(! ctx._source.locaties.contains(params.item)){" + + "ctx._source.locaties.add(params.item)" + + "}") .Params(objects => objects.Add(key: "item", locatie)))); if (!response.IsValid)