运行重置操作时 Azure 搜索索引器客户端超时

问题描述

我有一个 Azure sql 索引器,我需要索引的视图中有超过 60 万行。该视图最初需要几分钟来计算,这似乎会导致重置索引器或更改其配置出现问题。

private readonly SearchIndexerClient _indexerClient;    

private async Task<SearchIndexer> CreateOrUpdateIndexer(string indexName,string indexerName,IsqlServerIndexerConnectionProvider connectionProvider,IIndexerConfigurationProvider cfgProvider)
    {
        var indexer = new SearchIndexer(name: indexerName,dataSourceName: indexerName,indexName)
        {
            Schedule = new IndexingSchedule(cfgProvider.IndexingSchedule ?? TimeSpan.FromMinutes(5)),Parameters = GetIndexerParameters(connectionProvider,cfgProvider)
        };

        if (await _indexerClient.IndexerExistsAsync(indexerName))
        {
            await _indexerClient.ResetIndexerAsync(indexerName); // <<--- This one times out
        }

        return await _indexerClient.CreateOrUpdateIndexerAsync(indexer);
    }

基于分析会话,我可以得出结论,在更改索引器配置或重置索引器之后,正在查询数据源(在我的情况下,它是 sql 视图) - 但在完全重新索引之前,这是一个长期运行的操作。我不清楚为什么需要这样做,但我认为可以在客户端上设置更长的超时时间,我尝试过:

var clientOpts = new Azure.Search.Documents.SearchClientOptions
{
    Retry = { NetworkTimeout = TimeSpan.FromMinutes(15) }
};
return new SearchIndexerClient(
    MakeEndpointFromOpts(options),new AzureKeyCredential(options.AdminKey),clientOpts  // <<--- Configured the network timeout when building the Indexer Client
);

但无济于事,根据 azure 门户,重置操作连续运行了 100 毫秒和多次,并且在运行 ResetIndexerAsync 时出现“任务已取消”异常。

我目前的假设是超时的不是http客户端,而是搜索引擎本身内部的“重置”操作,它等待对数据源的调用。我不清楚这是否是可配置的,或者我必须解决这个限制,甚至为什么重置操作需要调用数据源。

我可以执行任何配置来避免这种行为吗?这只是在重置索引或执行完全爬网时出现的问题。此后每次增量抓取平均不到一分钟。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)