Azure Библиотека Bulk-Executor Cosmos - {\ "Ошибки \": [\ "Введено недопустимое содержимое, поскольку требуемые свойства - 'id;' - отсутствуют \"]} - PullRequest
0 голосов
/ 09 июля 2020

Я пытаюсь выполнить массовую вставку документов / Json с использованием Azure библиотеки Bulk Executor. Я использовал подход, описанный здесь Azure Документация: https://docs.microsoft.com/en-us/azure/cosmos-db/bulk-executor-java

Ниже приведено создание DocumentClient:

  public static DocumentClient documentClientFrom(BulkExecutionConfiguration cfg) throws DocumentClientException {
    
    ConnectionPolicy policy = new ConnectionPolicy();
    RetryOptions retryOptions = new RetryOptions();
    retryOptions.setMaxRetryAttemptsOnThrottledRequests(0);
    policy.setRetryOptions(retryOptions);
    policy.setConnectionMode(cfg.getConnectionMode());
    policy.setMaxPoolSize(cfg.getMaxConnectionPoolSize());
    
    return new DocumentClient(cfg.getServiceEndpoint(), cfg.getMasterKey(), policy, cfg.getConsistencyLevel());
}

Когда я пытаюсь выполнить массовую import, как показано ниже:

BulkImportResponse bulkImportResponse = bulkExecutor.importAll( documents, false, true, null );

Я получаю сообщение об ошибке:

com.microsoft.azure.documentdb.DocumentClientException: Message: {"Errors":["Encountered exception 
while executing function. Exception = Error: {\"Errors\":[\"The input content is invalid because the 
required properties - 'id; ' - are missing\"]}\r\nStack trace: Error: {\"Errors\":[\"The input 
content is invalid because the required properties - 'id; ' - are missing\"]}\n   at createCallback 
(script.js:6223:26)\n   at Anonymous function (script.js:686:29)"]}
ActivityId: 3b6ca789-508d-40a2-bda1-b4e424dac88f, Request URI: /apps/6ec7164c-b528-494b-b40e- 
249832f34bb1/services/221058a8-0299-4341-ad5a-0ea3d0a49cc1/partitions/ebae0619-6126-453c-b6a1- 
774739a52a71/replicas/132378420031633670p/, RequestStats: 
RequestStartTime: 2020-07-08T10:55:11.7899079Z, RequestEndTime: 2020-07-08T10:55:11.7999008Z,  Number 
of regions attempted:1
ResponseTime: 2020-07-08T10:55:11.7999008Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod- 
southcentralus1-fd11.documents.azure.com:14397/apps/6ec7164c-b528-494b-b40e- 
249832f34bb1/services/221058a8-0299-4341-ad5a-0ea3d0a49cc1/partitions/ebae0619-6126-453c-b6a1- 
774739a52a71/replicas/132378420031633670p/, LSN: 105, GlobalCommittedLsn: 105, PartitionKeyRangeId: 
0, IsValid: True, StatusCode: 400, SubStatusCode: 400, RequestCharge: 4.38, ItemLSN: -1, 
SessionToken: -1#105, UsingLocalLSN: False, TransportException: null, ResourceType: StoredProcedure, 
OperationType: ExecuteJavaScript
, SDK: Microsoft.Azure.Documents.Common/2.11.0, StatusCode: BadRequest
at com.microsoft.azure.documentdb.internal.ErrorUtils.maybeThrowException(ErrorUtils.java:74)
at com.microsoft.azure.documentdb.internal.GatewayProxy.performPostRequest(GatewayProxy.java:284)
at com.microsoft.azure.documentdb.internal.GatewayProxy.doExecute(GatewayProxy.java:108)
at com.microsoft.azure.documentdb.internal.GatewayProxy.processMessage(GatewayProxy.java:360)
at com.microsoft.azure.documentdb.DocumentClient$5.apply(DocumentClient.java:3037)
at com.microsoft.azure.documentdb.internal.RetryUtility.executeDocumentClientRequest(RetryUtility.java:73)
at com.microsoft.azure.documentdb.DocumentClient.doCreate(DocumentClient.java:3042)
at com.microsoft.azure.documentdb.DocumentClient.executeStoredProcedure(DocumentClient.java:1571)
at com.microsoft.azure.documentdb.bulkexecutor.internal.BatchInserter$1.call(BatchInserter.java:186)
at com.microsoft.azure.documentdb.bulkexecutor.internal.BatchInserter$1.call(BatchInserter.java:158)
at com.microsoft.azure.documentdb.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
at com.microsoft.azure.documentdb.repackaged.com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
at com.microsoft.azure.documentdb.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Вот json для объекта, который я пытаюсь вставить:

.........

"grocinvoiceInd": "N",
"_id": {
    "transactionId": {
        "$numberLong": "<xxxxxx>"
    },
    "txnSeqNbr": 0
},
"sourceInfo": "<xxxxxxx>"
}

Похоже, что у него есть поле _id, но он не вставляет запись. Любая помощь приветствуется.

1 Ответ

1 голос
/ 09 июля 2020

необходимо, чтобы в документе было поле id, потому что вы создали коллекцию с ключом раздела, если вы создаете коллекцию с ключом раздела, все документы в этой коллекции должны иметь это свойство

https://docs.microsoft.com/en-us/azure/cosmos-db/partitioning-overview

Также, как описано в Azure документации https://docs.microsoft.com/en-us/azure/cosmos-db/bulk-executor-java "В настоящее время библиотека массового исполнителя поддерживается только Azure Cosmos DB SQL Аккаунты API и Gremlin API ». Учитывая это, мы, массовый исполнитель, в настоящее время может не работать с учетными записями хранения MongoDB.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...