public static GenericSearchDocument ToGenericElasticSearchDoc <TEvent>(
            this EventLog <TEvent> log,
            EventIndexDefinition <TEvent> indexDefinition) where TEvent : class
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in indexDefinition.Fields)
            {
                var val = field.GetEventLogValue(log)?.ToElasticSearchFieldValue();
                if (val != null)
                {
                    dictionary.Add(field.Name.ToElasticName(), val);
                }
            }

            var id = indexDefinition.KeyField().GetEventLogValue(log);

            dictionary.SetId(id.ToString());

            return(dictionary);
        }