remove the indexer plugin from constant search plugins (#8367)

This commit is contained in:
Mykhailo Pylyp
2020-12-14 18:07:26 +02:00
committed by GitHub
parent 64a864a332
commit 29752c72d0
3 changed files with 6 additions and 107 deletions

View File

@@ -16,7 +16,6 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
private readonly ISearch windowsIndexerSearch;
private const uint _fileAttributeHidden = 0x2;
private static readonly Regex _likeRegex = new Regex(@"[^\s(]+\s+LIKE\s+'([^']|'')*'\s+OR\s+", RegexOptions.Compiled);
public WindowsSearchAPI(ISearch windowsIndexerSearch, bool displayHiddenFiles = false)
{
@@ -24,7 +23,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
DisplayHiddenFiles = displayHiddenFiles;
}
public List<SearchResult> ExecuteQuery(ISearchQueryHelper queryHelper, string keyword, bool isFullQuery = false)
public List<SearchResult> ExecuteQuery(ISearchQueryHelper queryHelper, string keyword)
{
if (queryHelper == null)
{
@@ -35,17 +34,6 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
// Generate SQL from our parameters, converting the userQuery from AQS->WHERE clause
string sqlQuery = queryHelper.GenerateSQLFromUserQuery(keyword);
var simplifiedQuery = SimplifyQuery(sqlQuery);
if (!isFullQuery)
{
sqlQuery = simplifiedQuery;
}
else if (simplifiedQuery.Equals(sqlQuery, StringComparison.CurrentCultureIgnoreCase))
{
// if a full query is requested but there is no difference between the queries, return empty results
return results;
}
// execute the command, which returns the results as an OleDBResults.
List<OleDBResult> oleDBResults = windowsIndexerSearch.Query(queryHelper.ConnectionString, sqlQuery);
@@ -141,7 +129,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
queryHelper.QuerySorting = "System.DateModified DESC";
}
public IEnumerable<SearchResult> Search(string keyword, ISearchManager manager, bool isFullQuery = false, string pattern = "*", int maxCount = 30)
public IEnumerable<SearchResult> Search(string keyword, ISearchManager manager, string pattern = "*", int maxCount = 30)
{
if (manager == null)
{
@@ -151,12 +139,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
ISearchQueryHelper queryHelper;
InitQueryHelper(out queryHelper, manager, maxCount, DisplayHiddenFiles);
ModifyQueryHelper(ref queryHelper, pattern);
return ExecuteQuery(queryHelper, keyword, isFullQuery);
}
public static string SimplifyQuery(string sqlQuery)
{
return _likeRegex.Replace(sqlQuery, string.Empty);
return ExecuteQuery(queryHelper, keyword);
}
}
}