Answered by:
Windows Index Search SQL Group On

Question
-
Hi
It's more about a Windows Search in Index problematic, but I don't find an appropriate forum, as it's handle by a PowerShell script, I post it here. I'm sorry if it's not the appropriate forum
I'm trying to query Windows Index to retrieve emails with Windows Search SQL in a PowerShell script.
For a basic query (Select, From, Where), it's ok, i have no problem, but I want to group my results with GROUP ON and that's more problematic to handle results.
I have the following PowerShell script :$dbConnection = New-Object -ComObject ADODB.Connection $dbConnection.Open("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';") $localMailsRS = New-Object -ComObject ADODB.Recordset $localMailsRS.Open(" GROUP ON System.ItemFolderPathDisplay OVER (GROUP ON System.Message.FromAddress OVER (SELECT System.ItemName FROM SYSTEMINDEX))" , $dbConnection) While(-Not $localMailsRS.EOF) { echo "==================================================" $localMailsRS.Fields.Item('System.ItemFolderPathDisplay').value echo "==================================================" $localMailsRS.MoveNext() } $localMailsRS.Close();
(it's a simplified script for the example)
For a basic SQL Query, $localMailsRS.Fields.Item('System.MYELEMENT').value is enough to display results but with the GROUP ON, only $localMailsRS.Fields.Item('System.ItemFolderPathDisplay').value works, and I don't find how to access to remaining results.
Thanks for your help !- Edited by Quentin Birgaentzle Wednesday, February 27, 2019 4:06 PM
Wednesday, February 27, 2019 4:05 PM
Answers
-
That is the correct error. It tells me that your query has issues.
Download the SDK and read the docs and test the examples until you figure out what is wrong with your query.
Here are the latest examples and docs:
https://docs.microsoft.com/en-us/windows/desktop/search/-search-samples-ovw
https://docs.microsoft.com/en-us/windows/desktop/search/-search-3x-advancedquerysyntax
Search developers forum: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=windowsdesktopsearchdevelopment
\_(ツ)_/
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Friday, March 1, 2019 7:46 AM
- Marked as answer by Quentin Birgaentzle Thursday, March 7, 2019 8:48 AM
Thursday, February 28, 2019 9:22 AM
All replies
-
If you use ADO.Net and not old converted VBScript you will see the correct error message.
$sql = @' GROUP ON System.ItemFolderPathDisplay OVER (GROUP ON System.Message.FromAddress OVER (SELECT System.ItemName FROM SYSTEMINDEX)) '@ $conn = [System.Data.OleDb.OleDbConnection]::New('Provider=Search.CollatorDSO;Extended Properties="Application=Windows"') $conn.Open() $cmd = $conn.CreateCommand() $cmd.CommandText = $sql $rdr = $cmd.ExecuteReader() $dt = [System.Data.DataTable]::New() $dt.Load($rdr)
Your SQL is incorrectly formed for a dataset.
\_(ツ)_/
Wednesday, February 27, 2019 7:47 PM -
I have the following error with your script :
Exception calling "Load" with "1" argument(s): "You must release all line descriptors before getting new ones."
- Edited by Quentin Birgaentzle Thursday, February 28, 2019 9:10 AM
Thursday, February 28, 2019 9:10 AM -
That is the correct error. It tells me that your query has issues.
Download the SDK and read the docs and test the examples until you figure out what is wrong with your query.
Here are the latest examples and docs:
https://docs.microsoft.com/en-us/windows/desktop/search/-search-samples-ovw
https://docs.microsoft.com/en-us/windows/desktop/search/-search-3x-advancedquerysyntax
Search developers forum: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=windowsdesktopsearchdevelopment
\_(ツ)_/
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Friday, March 1, 2019 7:46 AM
- Marked as answer by Quentin Birgaentzle Thursday, March 7, 2019 8:48 AM
Thursday, February 28, 2019 9:22 AM -
Here is a c# example using the DataReader.
\_(ツ)_/
Thursday, February 28, 2019 9:29 AM