diff --git a/foreign dlls/Examine.dll b/foreign dlls/Examine.dll index 3f75ed99ec..59c1a6321f 100644 Binary files a/foreign dlls/Examine.dll and b/foreign dlls/Examine.dll differ diff --git a/foreign dlls/UmbracoExamine.dll b/foreign dlls/UmbracoExamine.dll index 0f6b50f945..2d9bbf42ec 100644 Binary files a/foreign dlls/UmbracoExamine.dll and b/foreign dlls/UmbracoExamine.dll differ diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index 191693e531..cf94ebf326 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -98,6 +98,9 @@ False ..\..\foreign dlls\ICSharpCode.SharpZipLib.dll + + C:\Users\Shannon\Documents\Visual Studio 2008\Projects\Umbraco\Branch-4.1\foreign dlls\Lucene.Net.dll + ..\..\foreign dlls\DLR 2.0 SP1\Microsoft.Scripting.dll @@ -666,6 +669,7 @@ + QuickSearch.ascx ASPXCodeBehind diff --git a/umbraco/presentation/umbraco/Search/ExamineEvents.cs b/umbraco/presentation/umbraco/Search/ExamineEvents.cs new file mode 100644 index 0000000000..6c9ef527ad --- /dev/null +++ b/umbraco/presentation/umbraco/Search/ExamineEvents.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using umbraco.BusinessLogic; +using Examine; +using UmbracoExamine; +using Lucene.Net.Documents; + +namespace umbraco.presentation.umbraco.Search +{ + /// + /// Used to wire up events for Examine + /// + public class ExamineEvents : ApplicationBase + { + + public ExamineEvents() + : base() + { + var indexer = ExamineManager.Instance.IndexProviderCollection["InternalIndexer"] as UmbracoExamineIndexer; + if (indexer != null) + { + indexer.DocumentWriting += new EventHandler(indexer_DocumentWriting); + } + + } + + void indexer_DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e) + { + if (e.Fields[UmbracoExamineIndexer.IndexTypeFieldName] == IndexTypes.Content && e.Fields.Keys.Contains("nodeName")) + { + //add the lower cased version + e.Document.Add(new Field("__nodeName", + e.Fields["nodeName"].ToLower(), + Field.Store.YES, + Field.Index.ANALYZED, + Field.TermVector.NO + )); + } + } + + + /// + /// Event handler to create a lower cased version of the node name, this is so we can support case-insensitive searching and still + /// use the Whitespace Analyzer + /// + /// + /// + //void ExamineEvents_GatheringNodeData(object sender, IndexingNodeDataEventArgs e) + //{ + // if (e.IndexType == UmbracoExamine.IndexTypes.Content && e.Fields.Keys.Contains("nodeName")) + // { + // //add the lower cased version + // e.Fields.Add("__nodeName", e.Fields["nodeName"].ToLower()); + // } + //} + + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs b/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs index a77c43e424..0c0b30afb6 100644 --- a/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs +++ b/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using UmbracoExamine; using System.Web.Script.Serialization; using Examine; +using Examine.LuceneEngine.SearchCriteria; namespace umbraco.presentation.umbraco.Search { @@ -30,10 +31,10 @@ namespace umbraco.presentation.umbraco.Search var txt = UmbracoContext.Current.Request["q"].ToLower(); //the app can be Content or Media only, otherwise an exception will be thrown - var app = "Content"; + var app = UmbracoExamine.IndexTypes.Content; if (!string.IsNullOrEmpty(UmbracoContext.Current.Request["app"])) { - app = UmbracoContext.Current.Request["app"]; + app = UmbracoContext.Current.Request["app"].ToLower(); } int limit; @@ -41,24 +42,29 @@ namespace umbraco.presentation.umbraco.Search { limit = 100; } - - + //if it doesn't start with "*", then search only nodeName and nodeId var internalSearcher = (app == "Member") ? UmbracoContext.Current.InternalMemberSearchProvider : UmbracoContext.Current.InternalSearchProvider; - var criteria = internalSearcher.CreateSearchCriteria(app); + + //create some search criteria, make everything combined to be 'And' and only search the current app + var criteria = internalSearcher.CreateSearchCriteria(app, Examine.SearchCriteria.BooleanOperation.And); + IEnumerable results; if (txt.StartsWith("*")) { + //TODO: Why is this here?? i don't understand. results = internalSearcher.Search("*", true); } else { - var operation = criteria.NodeName(txt); + var operation = criteria.Field("__nodeName", txt.MultipleCharacterWildcard()); + + // ensure the user can only find nodes they are allowed to see if (UmbracoContext.Current.UmbracoUser.StartNodeId > 0) { - operation.Or().Id(UmbracoContext.Current.UmbracoUser.StartNodeId); + operation = operation.And().Id(UmbracoContext.Current.UmbracoUser.StartNodeId); } results = internalSearcher.Search(operation.Compile());