@@ -210,6 +210,7 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
210
210
sortString += padLeft ( obj . searchImportance || 99 , 2 ) ;
211
211
sortString += padLeft ( obj . weighting || 9999 , 4 ) ;
212
212
sortString += obj . text ;
213
+ console . log ( sortString ) ;
213
214
return sortString ;
214
215
}
215
216
if ( filter ) {
@@ -244,9 +245,9 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
244
245
}
245
246
}
246
247
}
247
- var that = this , results = [ ] , moreCount = 0 , searchCriteria ;
248
+ var that = this , results = [ ] , moreCount = 0 , searchCriteria , multiMatchPossible = searchFor . includes ( ' ' ) , modifiedSearchStr = multiMatchPossible ? searchFor . split ( ' ' ) . join ( '|' ) : searchFor ;
248
249
// Removed the logic that preserved spaces when collection was specified because Louise asked me to.
249
- searchCriteria = { $regex : '^(' + searchFor . split ( ' ' ) . join ( '|' ) + ')' , $options : 'i' } ;
250
+ searchCriteria = { $regex : '^(' + modifiedSearchStr + ')' , $options : 'i' } ;
250
251
this . searchFunc ( searches , function ( item , cb ) {
251
252
var searchDoc = { } ;
252
253
if ( filter ) {
@@ -292,7 +293,9 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
292
293
resultObject = { } ;
293
294
extend ( resultObject , results [ resultPos ] ) ;
294
295
// If they have already matched then improve their weighting
295
- resultObject . addHits = Math . max ( ( resultObject . addHits || 9 ) - 1 , 1 ) ;
296
+ if ( multiMatchPossible ) {
297
+ resultObject . addHits = Math . max ( ( resultObject . addHits || 9 ) - 1 , 1 ) ;
298
+ }
296
299
// remove it from current position
297
300
results . splice ( resultPos , 1 ) ;
298
301
// and re-insert where appropriate
0 commit comments