private static void UpsertEntry(UpsertIndexEntry upsert, List <object> args, string indexName) { var geoField = string.Empty; var geoObject = (object)null; if (upsert.GeoObjects != null) { foreach (var(key, value) in upsert.GeoObjects) { if (value is Point point) { geoField = key; geoObject = new { lat = point.Coordinates.Latitude, lon = point.Coordinates.Longitude }; break; } } } if (upsert.Texts != null || geoObject != null) { args.Add(new { index = new { _id = upsert.DocId, _index = indexName } }); var texts = new Dictionary <string, string>(); foreach (var(key, value) in upsert.Texts) { var text = value; var languageCode = ElasticSearchIndexDefinition.GetFieldName(key); if (texts.TryGetValue(languageCode, out var existing)) { text = $"{existing} {value}"; } texts[languageCode] = text; } args.Add(new { appId = upsert.AppId.Id.ToString(), appName = upsert.AppId.Name, contentId = upsert.ContentId.ToString(), schemaId = upsert.SchemaId.Id.ToString(), schemaName = upsert.SchemaId.Name, serveAll = upsert.ServeAll, servePublished = upsert.ServePublished, texts, geoField, geoObject }); } }
public Task InitializeAsync( CancellationToken ct) { return(ElasticSearchIndexDefinition.ApplyAsync(client, indexName, ct)); }