public async Task <bool> CreateOrUpdateIndexAsync(string indexName, CreateIndexFieldsCallback createIndexFieldsCallback,
                                                          CreateIndexSuggesterCallback createSuggesterCallback, int creationDelay = 0)
        {
            try
            {
                var fields = new List <Field>();
                createIndexFieldsCallback.Invoke(
                    (name, type, isKey, isSearchable, isFilterable, isSortable, isFacetable, isRetrievable) =>
                {
                    fields.Add(new Field()
                    {
                        Name          = name,
                        Type          = GetEdmType(type),
                        IsKey         = isKey,
                        IsSearchable  = isSearchable,
                        IsFilterable  = isFilterable,
                        IsSortable    = isSortable,
                        IsFacetable   = isFacetable,
                        IsRetrievable = isRetrievable
                    });
                });

                var suggester = default(Suggester);
                createSuggesterCallback.Invoke((name, fieldNames) =>
                {
                    suggester = new Suggester
                    {
                        Name         = name,
                        SourceFields = fieldNames
                    };
                });

                var definition = new Index()
                {
                    Name   = indexName,
                    Fields = fields,
                };
                if (default(Suggester) != suggester)
                {
                    definition.Suggesters.Add(suggester);
                }

                var response = await searchClient.Indexes.CreateOrUpdateAsync(definition);

                await Task.Delay(creationDelay);

                return(true);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Error creating index: {ex.Message}\r\n");
            }
        }
        public bool CreateIndex(string indexName, CreateIndexFieldsCallback createIndexFieldsCallback, CreateIndexSuggesterCallback createSuggesterCallback)
        {
            try
            {
                var fields = new List <Field>();
                createIndexFieldsCallback.Invoke(
                    (name, type, isKey, isSearchable, isFilterable, isSortable, isFacetable, isRetrievable) =>
                {
                    fields.Add(new Field()
                    {
                        Name          = name,
                        Type          = GetEdmType(type),
                        IsKey         = isKey,
                        IsSearchable  = isSearchable,
                        IsFilterable  = isFilterable,
                        IsSortable    = isSortable,
                        IsFacetable   = isFacetable,
                        IsRetrievable = isRetrievable
                    });
                });

                var suggester = default(Suggester);
                createSuggesterCallback.Invoke((name, names) =>
                {
                    suggester = new Suggester
                    {
                        Name         = name,
                        SourceFields = names
                    };
                });

                var definition = new Index()
                {
                    Name   = indexName,
                    Fields = fields
                };
                if (default(Suggester) != suggester)
                {
                    definition.Suggesters.Add(suggester);
                }

                var response = searchClient.Indexes.Create(definition);
                return(response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Error creating index: {ex.Message}\r\n");
            }
        }