public void UploadSceneDocuments <T>(IEnumerable <T> sceneDocuments)
        {
            if (sceneDocuments == null)
            {
                throw new NullReferenceException();
            }

            SearchIndexClient indexClient = new SearchIndexClient(_config.Name, _config.SceneIndexName, _client.SearchCredentials);
            var actions = new List <IndexAction <T> >();

            foreach (var sceneDocument in sceneDocuments)
            {
                actions.Add(IndexAction.MergeOrUpload(sceneDocument));
            }
            var batch = IndexBatch.New(actions);

            try
            {
                indexClient.Documents.Index(batch);
            }
            catch (IndexBatchException ex)
            {
                _logger.Error(ex.Message);
                throw;
            }
            finally
            {
                indexClient.Dispose();
            }
        }
Beispiel #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _serviceClient.Dispose();
                _serviceClient = null;

                _searchClient.Dispose();
                _searchClient = null;

                _indexClient.Dispose();
                _indexClient = null;
            }

            _disposed = true;
        }