1

In Microsoft.Azure.Search.Data v10 when calling ISearchIndexClient.Documents.SearchAsync
I got a result with a ContinuationToken property.

In Azure.Search.Documents v11 I can't find it when calling SearchClient.SearchAsync
which - as far as I have found out - is the equal call.

LosManos
  • 7,195
  • 6
  • 56
  • 107

1 Answers1

1

I don't have a good way to explain it :) but please take a look at the code below. The code below fetches all documents from an index using continuation token:

using System;
using System.Threading.Tasks;
using Azure;
using Azure.Search.Documents;
using Azure.Search.Documents.Models;

namespace SO71052143
{
    class Program
    {
        private const string accountName = "account-name";
        private const string accountKey = "admin-key";
        private const string indexName = "index-name";

        static async Task Main(string[] args)
        {
            SearchClient client = new SearchClient(new Uri($"https://{accountName}.search.windows.net"), indexName,
                new AzureKeyCredential(accountKey));
            var results = (await client.SearchAsync<SearchDocument>("*"));
            var searchResults = results.Value.GetResultsAsync();
            string continuationToken = null;
            do
            {
                await foreach (var item in searchResults.AsPages(continuationToken))
                {
                    continuationToken = item.ContinuationToken;
                    var documents = item.Values;
                }
            } while (continuationToken != null);
        }
    }
}
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • That was convoluted. I have yet to find an example of how to use V11 properly. The update documentation https://learn.microsoft.com/en-us/azure/search/search-dotnet-sdk-migration-version-11 only hinted to the new names. – LosManos Feb 10 '22 at 16:33