public static GenericElasticSearchDocument ToGenericElasticSearchDoc <TFunctionMessage>(
            this FunctionCall <TFunctionMessage> functionCall,
            FunctionIndexDefinition <TFunctionMessage> indexDefinition) where TFunctionMessage : FunctionMessage, new()
        {
            var dictionary = new GenericElasticSearchDocument();

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

            var id = indexDefinition.KeyField().GetValue(functionCall);

            dictionary.SetId(id.ToString());

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

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

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

            dictionary.SetId(id.ToString());

            return(dictionary);
        }