컬렉션의 IndexingPolicy를 업데이트하려고합니다. 컬렉션 정의는 CreateDocumentCollectionIsNotExistsAsync를 사용할 때 잘 작동하지만 ReplaceDocumentCollectionAsync를 사용하여 Exising 컬렉션의 정의를 업데이트하려고하면 DocumentClientException이 throw됩니다. .NET 라이브러리 1.19.1 사용. 예외 세부 정보 :ReplaceDocumentCollectionAsync DocumentClientException을 던지고
DocDBTrace Error: 0 : DocumentClientException with status code NotFound, message: The value '' specified for query '$resolveFor' is invalid., inner exception: null, and response headers: null
DocDBTrace Error: 0 : Operation will NOT be retried. Current attempt 0, Exception: Microsoft.Azure.Documents.NotFoundException: The value '' specified for query '$resolveFor' is invalid., documentdb-dotnet-sdk/1.19.1 Host/64-bit MicrosoftWindowsNT/6.2.9200.0
at Microsoft.Azure.Documents.DocumentServiceRequest..ctor(OperationType operationType, ResourceType resourceType, String path, Stream body, AuthorizationTokenType authorizationTokenType, NameValueCollection headers)
at Microsoft.Azure.Documents.DocumentServiceRequest.Create(OperationType operationType, String relativePath, Resource resource, ResourceType resourceType, AuthorizationTokenType authorizationTokenType, NameValueCollection headers, SerializationFormattingPolicy formattingPolicy, JsonSerializerSettings settings)
at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentCollectionPrivateAsync>d__123.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass2.<<ExecuteAsync>b__0>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
코드로 업데이트되었습니다. 나는 Create/Modify 인덱스 코드를 공유하려고하므로 CreateDocumentCollectionIfNotExistAsync를 먼저 호출하고 콜렉션이 존재하면 가장 최근의 인덱스 정책과 일치하도록 인덱스 정책을 수정합니다.
DocumentCollection appCollection = new DocumentCollection();
appCollection.Id = CosmosDbCollectionName;
// Set the index policy
var rrdc = await cdbClient.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri(CosmosDbDatabaseName), appCollection);
if (true == rrdc.StatusCode.IsSuccessCode())
{
// If OK was returned, the collection already existed.
if (HttpStatusCode.OK == rrdc.StatusCode)
{
var rr = await _cdbClient.ReplaceDocumentCollectionAsync(appCollection).ConfigureAwait(false);
if (false == rr.StatusCode.IsSuccessCode())
return false;
}
}
'DocumentClient.ReplaceDocumentCollectionAsync()'에 대한 호출이 어떻게 생겼습니까? –