2016-11-07 39 views
5

我正在使用Azure Search .Net SDK。任務被取消 - 這是什麼意思?

我打電話同步(不是異步)函數是這樣的:

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: 

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__15 3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.<SearchAsync>d__15 1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter 1.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, List 1 select, Nullable 1 skip, Nullable 1 top, String filter, Boolean includeTotalResultCount, List 1 orderBy) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 262 at MyApp.AzureSearch.AzureSearchService.SearchEmails(Guid userId, String origin, String searchText, Nullable 1 skip, Nullable 1 top, Boolean includeTotalResultCount, Boolean includeHtmlBody, Boolean orderByProcessedAscending, String interactionStatus) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 167 at MyApp.Domain.MyAppMessages.Command.MyAppMessagesAllNoticedUpdater.Handle(VisitorSession userSession, NoticeAllMyAppMessages processCommand) in c:\Projects\MyAppServer\src\MyApp.Domain\MyAppMessages\Command\MyAppMessagesAllNoticedUpdater.cs:line 30

回答

3

最有可能的,搜索完成之前,客戶端超時。您提交特別複雜的查詢時是否看到此錯誤?如果需要,您可以使用search traffic analytics查看服務中的搜索性能。

您看到「異步」異常的原因是API的同步版本只是異步基元的封裝。

+0

謝謝,我想它只是包裝一個異步功能。它根本不是一個複雜的查詢,查詢中的數據也很少。我沒想到.net SDK會拋出錯誤,除非在查詢中配置錯誤。是否有我可以處理的.net sdk可能引發的所有可能的錯誤列表? – richard

+0

可以拋出的主要異常是:'CloudException','IndexBatchException'(僅用於索引),'ValidationException',當然還有'OperationCanceledException'(或其子類'TaskCanceledException'你正在處理這裏)。但是由於C#不是檢查的異常語言,您可能也會看到其他異常(如ArgumentException)。 –