Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-CosmosDbDocument not able to query certain items from a container #465

Open
Sachin27j opened this issue Jan 13, 2023 · 3 comments
Open
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community. question The issue is a question.

Comments

@Sachin27j
Copy link

Version - PowerShell 5.1
Host - ISE, Also tested on Azure Automation Account
OS - Windows 10
CosmosDb Powershell version - 4.6.0

The following is returning me 0 items even though data is there in cosmosdb.
Upon changing the value in the filter for c.dwnStrmAppName to something else, it does give me an output.
Essentially, the cmd is working for some items with a certain partitionKey in cosmosdb but not working for others.

(Get-CosmosDbDocument -Context $newcosmosDbContext -CollectionId $cd_containerName -Query "SELECT c.createdOn FROM c WHERE c.env='preprod' and c.action='SPN Creation' and c.status='Success' and lower(c.dwnStrmAppName)=lower('XYZ')" -QueryEnableCrossPartition 1).createdOn |Select-Object -Last 1

@Sachin27j
Copy link
Author

Did some more digging, apparently the query is only running for one physical partition, while there exists 2 partitions for the collection I am running it for.
Anyone with any information related to this?

@PlagueHO PlagueHO added question The issue is a question. needs investigation The issue needs to be investigated by the maintainers or/and the community. labels Jan 21, 2023
@PlagueHO
Copy link
Owner

Hi @Sachin27j - Because you're doing a cross partition query (using the -QueryEnableCrossPartition parameter), it should be executing the query on all physical partitions. So, I don't see why your query wouldn't return the results you expect.

Have you run the same query in the Azure Portal in the Cosmos DB explorer - and do you get the same output?

@IAmWhitBran
Copy link

IAmWhitBran commented Jan 27, 2023

Hi, I am also getting this issue (or similar).
I have run the same query from the Azure portal as I have in my powershell instance. Powershell returns no record, Azure portal returns 1.

EDIT:
To update further, I can get the record to return by specifying the document id and partition key, though this does defeat the point of my cross partition query...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community. question The issue is a question.
Projects
None yet
Development

No branches or pull requests

3 participants