Beispiel #1
0
        private static async Task SeedCollectionAsync(string seedList, string indexName)
        {
            var result = new SearchInitResponse();

            try
            {
                var commandRepository = new SeachCommandRepository <TDocument>();
                {
                    await commandRepository.AzureSearchService.LoadIndexesAsync();

                    var seeds = JsonConvert.DeserializeObject <List <TDocument> >(seedList);
                    var del   = await commandRepository.DeleteIndex(indexName);

                    var insert = await commandRepository.CreateDocumentsInIndex(seeds, indexName);

                    if (!del)
                    {
                        result.MessageList.Add("Delete failed");
                    }

                    if (!insert)
                    {
                        result.MessageList.Add("Insert failed");
                    }
                }
            }
            catch (Exception ex)
            {
                ElmahLogger.LogError(ex);
            }
        }
Beispiel #2
0
        public static async Task Initialize(string seed, string indexName)
        {
            SearchInitResponse result = null;

            try
            {
                await SeedCollectionAsync(seed, indexName.ToLower());
            }
            catch (AzureSearchException de)
            {
                var baseException = de.GetBaseException();
                ElmahLogger.LogError(baseException);
            }
            catch (Exception e)
            {
                var baseException = e.GetBaseException();
                ElmahLogger.LogError(baseException);
            }
        }