From 42a54648a1dd078af8a069d8cb9254488e13fe8f Mon Sep 17 00:00:00 2001 From: Alekhya Reddy Date: Wed, 8 Apr 2020 17:51:43 -0700 Subject: [PATCH 1/2] Searches for keyword only in title and not content to improve the quality of results --- .../Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs index 857baea11b..972c809448 100644 --- a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs +++ b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs @@ -88,6 +88,9 @@ namespace Wox.Plugin.Indexer.SearchHelper // Set additional query restriction queryHelper.QueryWhereRestrictions = "AND scope='file:'"; + // To filter based on title for now + queryHelper.QueryContentProperties = "System.Title"; + // Set sorting order queryHelper.QuerySorting = "System.DateModified DESC"; } From 549d68d3e80d91164591493ab8433edd84c2fc9f Mon Sep 17 00:00:00 2001 From: Alekhya Reddy Date: Wed, 8 Apr 2020 18:16:40 -0700 Subject: [PATCH 2/2] Display the title from System.Title directly instead of extracting it from the path --- .../launcher/Plugins/Wox.Plugin.Indexer/Main.cs | 2 +- .../Wox.Plugin.Indexer/SearchHelper/SearchResult.cs | 4 ++++ .../SearchHelper/WindowsSearchAPI.cs | 13 ++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/Main.cs b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/Main.cs index b547815e76..d55b42671d 100644 --- a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/Main.cs +++ b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/Main.cs @@ -58,7 +58,7 @@ namespace Wox.Plugin.Indexer workingDir = Path.GetDirectoryName(path); Result r = new Result(); - r.Title = Path.GetFileName(path); + r.Title = searchResult.Title; r.SubTitle = path; r.IcoPath = path; r.Action = c => diff --git a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/SearchResult.cs b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/SearchResult.cs index fc4c0ed770..d43a0fc701 100644 --- a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/SearchResult.cs +++ b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/SearchResult.cs @@ -10,5 +10,9 @@ namespace Wox.Plugin.Indexer.SearchHelper { // Contains the Path of the file or folder public string Path { get; set; } + + // Contains the Title of the file or folder + public string Title { get; set; } + } } diff --git a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs index 972c809448..6d2b9b1881 100644 --- a/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs +++ b/src/modules/launcher/Plugins/Wox.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs @@ -34,10 +34,17 @@ namespace Wox.Plugin.Indexer.SearchHelper { if(WDSResults.HasRows) { - while (WDSResults.Read() && WDSResults.GetValue(0) != DBNull.Value) + while (WDSResults.Read()) { - var result = new SearchResult { Path = WDSResults.GetString(0) }; - _Result.Add(result); + if(WDSResults.GetValue(0) != DBNull.Value && WDSResults.GetValue(1) != DBNull.Value) + { + var result = new SearchResult + { + Path = WDSResults.GetString(0), + Title = WDSResults.GetString(1) + }; + _Result.Add(result); + } } } }