@@ -42,7 +42,7 @@ internal CSearchQueryHelper CreateQueryHelper()
42
42
43
43
// Get the ISearchQueryHelper which will help us to translate AQS --> SQL necessary to query the indexer
44
44
var queryHelper = catalogManager . GetQueryHelper ( ) ;
45
-
45
+
46
46
return queryHelper ;
47
47
}
48
48
@@ -81,11 +81,9 @@ private string QueryWhereRestrictionsFromLocationPath(string path, string search
81
81
var previousLevelDirectory = path . Substring ( 0 , indexOfSeparator ) ;
82
82
83
83
if ( string . IsNullOrEmpty ( itemName ) )
84
- return searchDepth + $ "{ previousLevelDirectory } '";
84
+ return $ "{ searchDepth } { previousLevelDirectory } '{ QueryOrderByFileNameRestriction } ";
85
85
86
- return $ "(System.FileName LIKE '{ itemName } %' " +
87
- $ "OR CONTAINS(System.FileName,'\" { itemName } *\" ',1033)) AND " +
88
- searchDepth + $ "{ previousLevelDirectory } '";
86
+ return $ "(System.FileName LIKE '{ itemName } %' OR CONTAINS(System.FileName,'\" { itemName } *\" ',1033)) AND { searchDepth } { previousLevelDirectory } ' { QueryOrderByFileNameRestriction } ";
89
87
}
90
88
91
89
///<summary>
@@ -98,7 +96,7 @@ public string QueryForTopLevelDirectorySearch(string path)
98
96
if ( path . LastIndexOf ( Constants . AllFilesFolderSearchWildcard ) > path . LastIndexOf ( Constants . DirectorySeperator ) )
99
97
return query + QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch ( path ) ;
100
98
101
- return query + QueryWhereRestrictionsForTopLevelDirectorySearch ( path ) ;
99
+ return query + QueryWhereRestrictionsForTopLevelDirectorySearch ( path ) + QueryOrderByFileNameRestriction ;
102
100
}
103
101
104
102
///<summary>
@@ -107,16 +105,17 @@ public string QueryForTopLevelDirectorySearch(string path)
107
105
public string QueryForAllFilesAndFolders ( string userSearchString )
108
106
{
109
107
// Generate SQL from constructed parameters, converting the userSearchString from AQS->WHERE clause
110
- return CreateBaseQuery ( ) . GenerateSQLFromUserQuery ( userSearchString ) + " AND " + QueryWhereRestrictionsForAllFilesAndFoldersSearch ( ) ;
108
+ return CreateBaseQuery ( ) . GenerateSQLFromUserQuery ( userSearchString ) + " AND " + QueryWhereRestrictionsForAllFilesAndFoldersSearch
109
+ + QueryOrderByFileNameRestriction ;
111
110
}
112
111
113
112
///<summary>
114
113
/// Set the required WHERE clause restriction to search for all files and folders.
115
114
///</summary>
116
- public string QueryWhereRestrictionsForAllFilesAndFoldersSearch ( )
117
- {
118
- return $ "scope='file:' ";
119
- }
115
+ public const string QueryWhereRestrictionsForAllFilesAndFoldersSearch = "scope='file:'" ;
116
+
117
+ public const string QueryOrderByFileNameRestriction = " ORDER BY System.FileName ";
118
+
120
119
121
120
///<summary>
122
121
/// Search will be performed on all indexed file contents for the specified search keywords.
@@ -125,7 +124,8 @@ public string QueryForFileContentSearch(string userSearchString)
125
124
{
126
125
string query = "SELECT TOP " + settings . MaxResult + $ " { CreateBaseQuery ( ) . QuerySelectColumns } FROM { SystemIndex } WHERE ";
127
126
128
- return query + QueryWhereRestrictionsForFileContentSearch ( userSearchString ) + " AND " + QueryWhereRestrictionsForAllFilesAndFoldersSearch ( ) ;
127
+ return query + QueryWhereRestrictionsForFileContentSearch ( userSearchString ) + " AND " + QueryWhereRestrictionsForAllFilesAndFoldersSearch
128
+ + QueryOrderByFileNameRestriction ;
129
129
}
130
130
131
131
///<summary>
0 commit comments