Skip to content

Commit a64efb9

Browse files
committed
Improved search with "and", partial match U4-2509
- added partial matching on each word. - fixed bug so 'all' words match rather than 'any' words.
1 parent cf9f11f commit a64efb9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Umbraco.Web/umbraco.presentation/umbraco/Search/QuickSearchHandler.ashx.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public void ProcessRequest(HttpContext context)
5959
}
6060
else
6161
{
62-
var operation = criteria.GroupedAnd(new[] { "__nodeName" }, txt.Split(' '));
62+
var words = txt.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.ToLower().MultipleCharacterWildcard()).ToList();
63+
var operation = criteria.GroupedOr(new[] { "__nodeName" }, new[] { words[0] });
64+
words.RemoveAt(0);
65+
foreach (var word in words)
66+
operation = operation.And().GroupedOr(new[] { "__nodeName" }, new[] { word });
6367

6468
// ensure the user can only find nodes they are allowed to see
6569
if (UmbracoContext.Current.UmbracoUser.StartNodeId > 0)

0 commit comments

Comments
 (0)