Improved search with "and", partial match U4-2509

- added partial matching on each word.
- fixed bug so 'all' words match rather than 'any' words.
This commit is contained in:
Shannon
2013-09-12 14:12:33 +10:00
parent e69b043cfa
commit 24471c32f9

View File

@@ -60,7 +60,11 @@ namespace umbraco.presentation.umbraco.Search
}
else
{
var operation = criteria.Field("__nodeName", txt.MultipleCharacterWildcard());
var words = txt.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.ToLower().MultipleCharacterWildcard()).ToList();
var operation = criteria.GroupedOr(new[] { "__nodeName" }, new[] { words[0] });
words.RemoveAt(0);
foreach (var word in words)
operation = operation.And().GroupedOr(new[] { "__nodeName" }, new[] { word });
// ensure the user can only find nodes they are allowed to see
if (UmbracoContext.Current.UmbracoUser.StartNodeId > 0)