Exemple #1
0
        public async Task Index()
        {
            await using SearchResources resources = await SearchResources.CreateWithEmptyHotelsIndexAsync(this);

            SearchClient client = resources.GetQueryClient();

            try
            {
                #region Snippet:Azure_Search_Tests_Samples_Readme_Index
                IndexDocumentsBatch <Hotel> batch = IndexDocumentsBatch.Create(
                    IndexDocumentsAction.Upload(new Hotel {
                    Id = "783", Name = "Upload Inn"
                }),
                    IndexDocumentsAction.Merge(new Hotel {
                    Id = "12", Name = "Renovated Ranch"
                }));

                IndexDocumentsOptions options = new IndexDocumentsOptions {
                    ThrowOnAnyError = true
                };
                client.IndexDocuments(batch, options);
                #endregion Snippet:Azure_Search_Tests_Samples_Readme_Index
            }
            catch (RequestFailedException)
            {
                // Ignore the non-existent merge failure
            }
        }
Exemple #2
0
        public async Task GetStastistics()
        {
            await using SearchResources search = await SearchResources.CreateWithEmptyHotelsIndexAsync(this);

            SearchServiceClient client = search.GetServiceClient();
            Response <SearchServiceStatistics> response = await client.GetStatisticsAsync();

            Assert.AreEqual(200, response.GetRawResponse().Status);
            Assert.IsNotNull(response.Value);
            Assert.IsNotNull(response.Value.Counters);
            Assert.IsNotNull(response.Value.Counters.DataSourceCounter);
            Assert.IsNotNull(response.Value.Counters.DocumentCounter);
            Assert.IsNotNull(response.Value.Counters.IndexCounter);
            Assert.IsNotNull(response.Value.Counters.IndexerCounter);
            Assert.IsNotNull(response.Value.Counters.StorageSizeCounter);
            Assert.IsNotNull(response.Value.Counters.SynonymMapCounter);
            Assert.IsNotNull(response.Value.Limits);

            Assert.NotZero(response.Value.Counters.IndexCounter.Quota ?? 0);
            Assert.AreEqual(1, response.Value.Counters.IndexCounter.Usage ?? 0);
        }