我正在使用Azure搜索.Net SDK。
我正在调用这样的同步(NOT ASYNC)函数:
var searchResults = searchIndexClient.Documents.Search<T>(searchText, searchParameters);
它通常有效。我没有使用任何异步函数,但不知何故,我刚刚得到的错误看起来像是异步错误:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
CancellationToken: IsCanceleationRequested=false
Task: Id = 556, Status = Canceled, Method = "{null}", Result = "{Not yet computed}"
StackTrace:
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__15
3.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- 在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.<SearchAsync>d__15
1.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- 在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.Search[T](IDocumentsOperations operations, String searchText, SearchParameters searchParameters, SearchRequestOptions searchRequestOptions) at MyApp.AzureSearch.AzureSearchService.PerformSearch[T](String searchText, SearchParameters searchParameters) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 359 at MyApp.AzureSearch.AzureSearchService.Search[T](String searchText, List
1个searchFields,SearchMode searchMode,List1 select, Nullable
1 skip,Nullable1 top, String filter, Boolean includeTotalResultCount, List
1 orderBy)in c:\ Projects \ MyAppServer \ src \ MyApp.AzureSearch \ AzureSearchService.cs:第262行 at MyApp.AzureSearch.AzureSearchService.SearchEmails(Guid userId,String origin,String searchText,Nullable1 skip, Nullable
1 top,Boolean includeTotalResultCount,Boolean includeHtmlBody,Boolean orderByProcessedAscending,String interactionStatus)in c:\ Projects \ MyAppServer \ src \ MyApp .AzureSearch \ AzureSearchService.cs:第167行 at MyApp.Domain.MyAppMessages.Command.MyAppMessagesAllNoticedUpdater.Handle(VisitorSession userSession,NoticeAllMyAppMessages processCommand)位于c:\ Projects \ MyAppServer \ src \ MyApp.Domain \ MyAppMessages \ Command \ MyAppMessagesAllNoticedUpdater.cs:第30行
答案 0 :(得分:5)
最有可能的是,客户端超时在搜索完成之前已过期。提交特别复杂的查询时,您是否看到此错误?如果需要,您可以使用search traffic analytics查看服务中的搜索效果。
您之所以看到&#34;异步&#34;异常是API的同步版本只是异步原语的包装器。
答案 1 :(得分:0)
传递CancellationToken = null并将代码设为异步方法。