Azure.Search.Documents v11 中的 ContinuationToken 在哪里
Where is ContinuationToken in Azure.Search.Documents v11
在Microsoft.Azure.Search.Data v10
时调用ISearchIndexClient.Documents.SearchAsync
我得到了 ContinuationToken
属性.
的结果
在Azure.Search.Documents v11
调用时找不到SearchClient.SearchAsync
据我所知,这是平等的呼唤。
我没有很好的方法来解释它 :) 但请看下面的代码。下面的代码使用延续标记从索引中获取所有文档:
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);
}
}
}
在Microsoft.Azure.Search.Data v10
时调用ISearchIndexClient.Documents.SearchAsync
我得到了 ContinuationToken
属性.
在Azure.Search.Documents v11
调用时找不到SearchClient.SearchAsync
据我所知,这是平等的呼唤。
我没有很好的方法来解释它 :) 但请看下面的代码。下面的代码使用延续标记从索引中获取所有文档:
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);
}
}
}