[BUG] Need a way to inject partitionKey for CosmosContainer.queryItems method
See original GitHub issueDescription
I’m trying to use the method CosmosContainer.queryItems
to query db.
However, I am not able to set partition key in CosmosQueryRequestOptions, as the setters is of default type.
Also, ModelBridgeInternal doesn’t have a means to equip CosmosQueryRequestOptions with partition key.
Expected behaviour
Need a way to inject partition key in CosmosContainer.queryItems
method
SDK version:
- 4.2.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Container.GetItemQueryIterator Method - Microsoft Learn
This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It...
Read more >Can we use cosmosContainer.queryItems() method to execute ...
I have a Java method in my code, in which I am using following line of code to fetch any data from azure...
Read more >Azure Cosmos Database — CRUD using Azure Cosmos SDK
Let's check how many items were inserted in the Cosmos Container. The below query shows how many items we have per partition.
Read more >Index (Azure SDK for Java Reference Documentation) - NET
Specifies the options associated with change feed methods (enumeration ... Encapsulates error related details in the Azure Cosmos DB database service.
Read more >Azure Cosmos DB support for Java source code
Insert. Methods supported for insertv - v2. com.microsoft.azure.documentdb. ... Links are created for transaction and function point needs: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, you should be able to call
CosmosItemResponse#getItem()
API - and that will return the saved response object in the same Object model that you provided it with initially. Make sure you enable this propertycontentResponseOnWriteEnabled
inCosmosClientBuilder
because SDK doesn’t return full responses by default for write operations.Read the docs and it should be clear on how and when to use it : https://github.com/Azure/azure-sdk-for-java/blob/azure-cosmos_4.2.0/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java#L362
@kushagraThapar Probably I had checked the wrong version. I can see the setter public in V4.2. Thank you. Will close the issue.
Also, I use
ModelsBridgeInternal.getInternalObjectNode(CosmosItemResponse)
to retrieve id and partition key from CosmosItemResponse… Is it discouraged to useModelsBridgeInternal
for this task…Is there an alternative ?