[BUG] - Submit-PnPSearchQuery -All fails when SharePoint rejects its internal [DocId] sort
Reporting an Issue or Missing Feature
Submit-PnPSearchQuery -All fails in my SharePoint Online environment because its internal paging uses a [DocId] sort syntax that the search service rejects.
I checked the PnP.PowerShell 3.4.1 implementation: the -All branch sets SortList to [DocId] ascending and uses IndexDocId for subsequent pages. This replaces a caller-supplied SortList. This appears to be an issue in the Submit-PnPSearchQuery cmdlet, rather than the PnP Framework Provisioning Engine.
Source: SubmitSearchQuery.cs, v3.4.1
Expected behavior
-All should retrieve all matching results using DocId sort syntax accepted by SharePoint Search. If the required sort syntax is not accepted, the command should report the failure clearly rather than presenting it as an empty result set.
Actual behavior
In the affected tenant, [DocId] and DocId sort syntax fail with:
We didn’t understand your search terms.
The lowercase forms docid and docId work in the same environment. The same query without -All, using -MaxResults 500, returned 13 results.
A supplied SortList does not avoid the failure because the -All implementation replaces it with its internal [DocId] sort.
Separately, with PnP.PowerShell 2.12.0, -All -RetryCount 0 surfaced the error. With retries enabled, the error could be logged while the command returned zero rows. That zero-row result was not a successful search. This retry behavior is related but distinct; see PnP issue #4758 and PR #4784.
Steps to reproduce behavior
Authenticate with a PnP connection, then run:
$query = 'DepartmentId:<hub-site-guid> ContentTypeId:0x010100* PromotedState:0'
Submit-PnPSearchQuery
-Query $query
-All
-RetryCount 0
-Connection $connection
In my environment, the query succeeds without -All:
Submit-PnPSearchQuery
-Query $query
-MaxResults 500
-RetryCount 0
-Connection $connection
It returned 13 rows. I also tested manual paging with IndexDocId and lowercase docid: pages of 5, 5, and 3 returned 13 unique rows matching the baseline on both tested PnP versions. This did not test a result set larger than 500.
Related SharePoint Search reports: issue #11043 and issue #9728.
What is the version of the Cmdlet module you are running?
PnP.PowerShell 3.4.1 Compared with PnP.PowerShell 2.12.0 PowerShell 7.6.7
Which operating system/environment are you running PnP PowerShell on?
- [X] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Thanks for reporting the issue @iamtobbe and linking to other related issues. I could reproduce the issue on my client's tenant with both parameters 'All' and 'SortList'. Nothing has changed related to the cmdlet within the repo. It feels like a backend issue with MS and would need to wait for them to fix it.
Hi @reshmee011,
Thank you for your response. I suspected this might be a platform issue.
Does the PnP PowerShell community report or escalate these types of issues to Microsoft?
Best regards, Tobias
@iamtobbe : We don't normally report those issues directly to Microsoft and rely on the community to do so if we suspect it's a backend issue by replicating the issue using MS REST /Graph/CSOM APIs.
Hello, Do we have any updates on this issue? It seems to affect many (almost all) of our scripts
I can confirm the same behavior with PnP.PowerShell 3.1.0. The query works without -All, but fails as soon as -All is added with We didn't understand your search terms. Make sure they're using proper syntax.
Minimal reproduction: Submit-PnPSearchQuery -Query "*" -All -SelectProperties Path
The same query without -All works correctly.
Thanks @fvancaelenbergnbb for testing, it confirms nothing changed in those cmdlets between the versions.
@fvancaelenbergnbb , @iamtobbe , @chetan-mahajan-dnv , a PR #5508 was merged to fix the issue, can you please test against the latest release.
Using the following commands:
- $query = "IsDocument:true"
- Submit-PnPSearchQuery -Query $query -MaxResults 500 -RetryCount 0
- Submit-PnPSearchQuery -Query $query -All -RetryCount 0
Using Version 3.5.0 I still get the message "Submit-PnPSearchQuery: We didn't understand your search terms. Make sure they're using proper syntax." when executing command 3. Executing command 2 results in some rows.
Using Version 3.5.4-nightly both command (2 and 3) result in rows.
I conclude that the issue was correctly fixed.
When can we expect this to be avaliable in a regular release?
@PaoloBonaSogeti : Thanks so much for testing the latest nightly release. It will be shared when the next release is ready. @gautamdsheth , any ideas?