diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj
index 821c92714..b5a192c90 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj
@@ -17,6 +17,7 @@
+
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
index b311b0b1d..59ff420dc 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
@@ -1,12 +1,16 @@
using Microsoft.Search.Interop;
using System;
using System.Collections.Generic;
-using System.Text;
+using System.Data.OleDb;
namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
{
public class QueryConstructor
{
+ public OleDbConnection conn;
+ public OleDbCommand command;
+ public OleDbDataReader dataReaderResults;
+
private Settings _settings;
private const string SystemIndex = "SystemIndex";
@@ -18,14 +22,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
public CSearchQueryHelper CreateBaseQuery()
{
- // This uses the Microsoft.Search.Interop assembly
- CSearchManager manager = new CSearchManager();
-
- // SystemIndex catalog is the default catalog in Windows
- ISearchCatalogManager catalogManager = manager.GetCatalog(SystemIndex);
-
- // Get the ISearchQueryHelper which will help us to translate AQS --> SQL necessary to query the indexer
- var baseQuery = catalogManager.GetQueryHelper();
+ var baseQuery = CreateQueryHelper();
// Set the number of results we want. Don't set this property if all results are needed.
baseQuery.QueryMaxResults = _settings.MaxResult;
@@ -33,7 +30,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
// Set list of columns we want to display, getting the path presently
baseQuery.QuerySelectColumns = "System.FileName, System.ItemPathDisplay";
- // Filter based on folder/file name
+ // Filter based on file name
baseQuery.QueryContentProperties = "System.FileName";
// Set sorting order
@@ -42,6 +39,20 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
return baseQuery;
}
+ internal CSearchQueryHelper CreateQueryHelper()
+ {
+ // This uses the Microsoft.Search.Interop assembly
+ var manager = new CSearchManager();
+
+ // SystemIndex catalog is the default catalog in Windows
+ var catalogManager = manager.GetCatalog(SystemIndex);
+
+ // Get the ISearchQueryHelper which will help us to translate AQS --> SQL necessary to query the indexer
+ var queryHelper = catalogManager.GetQueryHelper();
+
+ return queryHelper;
+ }
+
///
/// Set the required WHERE clause restriction to search on the first level of a specified directory.
///
@@ -67,7 +78,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
///
public string QueryForAllFilesAndFolders(string userSearchString)
{
- // Generate SQL from our parameters, converting the userQuery from AQS->WHERE clause
+ // Generate SQL from constructed parameters, converting the userSearchString from AQS->WHERE clause
return CreateBaseQuery().GenerateSQLFromUserQuery(userSearchString) + " AND " + QueryWhereRestrictionsForAllFilesAndFoldersSearch();
}
@@ -78,5 +89,40 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
{
return $"scope='file:'";
}
+
+ internal List ExecuteWindowsIndexSearch(string query)
+ {
+ var results = new List();
+
+ using (conn = new OleDbConnection(CreateQueryHelper().ConnectionString))
+ {
+ conn.Open();
+
+ using (command = new OleDbCommand(query, conn))
+ {
+ // Results return as an OleDbDataReader.
+ using (dataReaderResults = command.ExecuteReader())
+ {
+ if (dataReaderResults.HasRows)
+ {
+ while (dataReaderResults.Read())
+ {
+ if (dataReaderResults.GetValue(0) != DBNull.Value && dataReaderResults.GetValue(1) != DBNull.Value)
+ {
+ var result = new Result
+ {
+ Title = dataReaderResults.GetString(0),
+ SubTitle = dataReaderResults.GetString(1)
+ };
+ results.Add(result);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return results;
+ }
}
}