static DbCaption CreatePart(DbCaption c, CaptionPart part) { var partCaption = c.JsonClone(); partCaption.caption_id = $"{c.video_id}|{part.ToString().ToLowerInvariant()}"; partCaption.caption = part switch { CaptionPart.Title => c.video_title, CaptionPart.Description => c.description, CaptionPart.Keywords => c.keywords, _ => throw new NotImplementedException($"can't create part `{part}`") }; partCaption.part = part; return(partCaption); } // instead of searching across title, description, captions. We create new caption records for each part var caps = dbCaption.caption_group == 0 ? new[] { dbCaption, CreatePart(dbCaption, CaptionPart.Title), CreatePart(dbCaption, CaptionPart.Description), CreatePart(dbCaption, CaptionPart.Keywords) } : new[] { dbCaption }; foreach (var newCap in caps) { // even tho we use EsCaption in the NEST api, it will still serialize and store instance properties. Remove the extra ones newCap.keywords = null; newCap.description = null; } return(caps); }
static IEnumerable <DbCaption> SelectCaptions(DbCaption dbCaption) {