From 24471c32f92ee9fa0e4c9db44072f082d6d188b9 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 12 Sep 2013 14:12:33 +1000 Subject: [PATCH] Improved search with "and", partial match U4-2509 - added partial matching on each word. - fixed bug so 'all' words match rather than 'any' words. --- .../umbraco/Search/QuickSearchHandler.ashx.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Search/QuickSearchHandler.ashx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Search/QuickSearchHandler.ashx.cs index 2950f072bc..7d939e5809 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Search/QuickSearchHandler.ashx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Search/QuickSearchHandler.ashx.cs @@ -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)