From 58537ce11aa253aa7b7b71e024b2271ee18c6eef Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2020 15:21:58 +1100 Subject: [PATCH 01/16] Updates to newer 2.0 version of Examine which has Examine.Core as netstandard --- NuGet.Config | 2 +- src/Umbraco.Examine/Umbraco.Examine.csproj | 7 +- .../PublishedMediaCache.cs | 18 +-- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 2 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 6 +- .../UmbracoExamine/ExamineExtensions.cs | 134 ++++++++++++++++++ src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 1 - src/Umbraco.Web/PublishedContentExtensions.cs | 5 +- src/Umbraco.Web/Runtime/WebInitialComposer.cs | 2 +- src/Umbraco.Web/Search/ExamineComposer.cs | 5 - src/Umbraco.Web/Umbraco.Web.csproj | 3 +- 12 files changed, 154 insertions(+), 33 deletions(-) create mode 100644 src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs diff --git a/NuGet.Config b/NuGet.Config index 7d786702f4..64425091dc 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -7,6 +7,6 @@ --> - + diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj index a3adcb56b7..047fb7813e 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -49,7 +49,12 @@ - + + 2.0.0 + + + 2.0.0 + 1.0.0-beta2-19554-01 runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs index 8594b07692..f913d1c9b8 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs @@ -43,6 +43,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private readonly IEntityXmlSerializer _entitySerializer; private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly IVariationContextAccessor _variationContextAccessor; + private readonly IExamineManager _examineManager = new ExamineManager(); // must be specified by the ctor private readonly IAppCache _appCache; @@ -229,29 +230,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache public override bool HasContent(bool preview) { throw new NotImplementedException(); } - private static IExamineManager GetExamineManagerSafe() - { - try - { - return ExamineManager.Instance; - } - catch (TypeInitializationException) - { - return null; - } - } - private ISearcher GetSearchProviderSafe() { if (_searchProvider != null) return _searchProvider; - var eMgr = GetExamineManagerSafe(); - if (eMgr == null) return null; - try { - return eMgr.TryGetIndex(Constants.UmbracoIndexes.InternalIndexName, out var index) ? index.GetSearcher() : null; + return _examineManager.TryGetIndex(Constants.UmbracoIndexes.InternalIndexName, out var index) ? index.GetSearcher() : null; } catch (FileNotFoundException) { diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index 9ba5c4bb91..27113bdc79 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -108,7 +108,7 @@ namespace Umbraco.Tests.Runtimes composition.RegisterUnique(f => new DistributedCache(f.GetInstance(), f.GetInstance())); composition.WithCollectionBuilder().Append(); composition.RegisterUnique(); - composition.RegisterUnique(f => ExamineManager.Instance); + composition.RegisterUnique(); composition.RegisterUnique(); composition.RegisterUnique(); composition.RegisterUnique(_ => new MediaUrlProviderCollection(Enumerable.Empty())); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index d664b4823c..93a3e52446 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -393,7 +393,7 @@ namespace Umbraco.Tests.Testing Composition.RegisterUnique(factory => factory.GetInstance().Content); Composition.RegisterUnique(factory => factory.GetInstance().WebRouting); - Composition.RegisterUnique(factory => ExamineManager.Instance); + Composition.RegisterUnique(); Composition.RegisterUnique(); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index a06c0c0b25..2892e39b49 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -78,13 +78,14 @@ - + + 2.0.0 + 1.8.14 - @@ -146,6 +147,7 @@ + diff --git a/src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs b/src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs new file mode 100644 index 0000000000..9cca58719e --- /dev/null +++ b/src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs @@ -0,0 +1,134 @@ +using Examine; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Xml.Linq; + +namespace Umbraco.Tests.UmbracoExamine +{ + /// + /// LEGACY!! Static methods to help query umbraco xml + /// + /// + /// This should be deleted when we remove the old xml published content with tests which should be replaced with nucache tests + /// + internal static class ExamineExtensions + { + /// + /// Returns true if the XElement is recognized as an umbraco xml NODE (doc type) + /// + /// + /// + internal static bool IsExamineElement(this XElement x) + { + var id = (string)x.Attribute("id"); + if (string.IsNullOrEmpty(id)) + return false; + int parsedId; + if (int.TryParse(id, out parsedId)) + if (parsedId > 0) + return true; + return false; + } + + /// + /// This takes into account both schemas and returns the node type alias. + /// If this isn't recognized as an element node, this returns an empty string + /// + /// + /// + internal static string ExamineNodeTypeAlias(this XElement x) + { + return string.IsNullOrEmpty((string)x.Attribute("nodeTypeAlias")) + ? x.Name.LocalName + : (string)x.Attribute("nodeTypeAlias"); + } + + /// + /// Returns umbraco value for a data element with the specified alias. + /// + /// + /// + /// + internal static string SelectExamineDataValue(this XElement xml, string alias) + { + XElement nodeData = null; + + //if there is data children with attributes, we're on the old + if (xml.Elements("data").Any(x => x.HasAttributes)) + nodeData = xml.Elements("data").SingleOrDefault(x => string.Equals((string)x.Attribute("alias"), alias, StringComparison.InvariantCultureIgnoreCase)); + else + nodeData = xml.Elements().FirstOrDefault(x => string.Equals(x.Name.ToString(), alias, StringComparison.InvariantCultureIgnoreCase)); + + if (nodeData == null) + return string.Empty; + + if (!nodeData.HasElements) + return nodeData.Value; + + //it has sub elements so serialize them + var reader = nodeData.CreateReader(); + reader.MoveToContent(); + return reader.ReadInnerXml(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public static ValueSet ConvertToValueSet(this XElement xml, string indexCategory) + { + if (!xml.IsExamineElement()) + throw new InvalidOperationException("Not a supported Examine XML structure"); + var allVals = xml.SelectExamineAllValues(); + var id = (string)xml.Attribute("id"); + //we will use this as the item type, but we also need to add this as the 'nodeTypeAlias' as part of the properties + //since this is what Umbraco expects + var nodeTypeAlias = xml.ExamineNodeTypeAlias(); + var set = new ValueSet(id, indexCategory, nodeTypeAlias, allVals); + set.Set("nodeTypeAlias", nodeTypeAlias); + return set; + } + + internal static Dictionary SelectExamineAllValues(this XElement xml) + { + var attributeValues = xml.Attributes().ToDictionary(x => x.Name.LocalName, x => x.Value); + var dataValues = xml.SelectExamineDataValues(); + foreach (var v in attributeValues) + //override the data values with attribute values if they do match, otherwise add + dataValues[v.Key] = v.Value; + return dataValues; + } + + internal static Dictionary SelectExamineDataValues(this XElement xml) + { + //resolve all element data at once since it is much faster to do this than to relookup all of the XML data + //using Linq and the node.Elements() methods re-gets all of them. + var elementValues = new Dictionary(); + foreach (var x in xml.Elements()) + { + if (x.Attribute("id") != null) + continue; + + string key; + if (x.Name.LocalName == "data") + //it's the legacy schema + key = (string)x.Attribute("alias"); + else + key = x.Name.LocalName; + + if (string.IsNullOrEmpty(key)) + continue; + + if (!x.HasElements) + elementValues[key] = x.Value; + else + //it has sub elements so serialize them + using (var reader = x.CreateReader()) + { + reader.MoveToContent(); + elementValues[key] = reader.ReadInnerXml(); + } + } + return elementValues; + } + } +} diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index ae42f0dd75..56bd423678 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -86,7 +86,6 @@ - diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index d02e5a3197..223b7dbaf1 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -28,6 +28,7 @@ namespace Umbraco.Web private static UmbracoContext UmbracoContext => Current.UmbracoContext; private static ISiteDomainHelper SiteDomainHelper => Current.Factory.GetInstance(); private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor; + private static IExamineManager ExamineManager => Current.Factory.GetInstance(); #region IsComposedOf @@ -198,7 +199,7 @@ namespace Umbraco.Web // TODO: inject examine manager indexName = string.IsNullOrEmpty(indexName) ? Constants.UmbracoIndexes.ExternalIndexName : indexName; - if (!ExamineManager.Instance.TryGetIndex(indexName, out var index)) + if (!ExamineManager.TryGetIndex(indexName, out var index)) throw new InvalidOperationException("No index found with name " + indexName); var searcher = index.GetSearcher(); @@ -219,7 +220,7 @@ namespace Umbraco.Web // TODO: inject examine manager indexName = string.IsNullOrEmpty(indexName) ? Constants.UmbracoIndexes.ExternalIndexName : indexName; - if (!ExamineManager.Instance.TryGetIndex(indexName, out var index)) + if (!ExamineManager.TryGetIndex(indexName, out var index)) throw new InvalidOperationException("No index found with name " + indexName); var searcher = index.GetSearcher(); diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index 4cb256e44a..d34398e066 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -149,7 +149,7 @@ namespace Umbraco.Web.Runtime composition.RegisterUnique(); - composition.RegisterUnique(factory => ExamineManager.Instance); + composition.RegisterUnique(); // configure the container for web composition.ConfigureForWeb(); diff --git a/src/Umbraco.Web/Search/ExamineComposer.cs b/src/Umbraco.Web/Search/ExamineComposer.cs index d62fc97efb..9d8af5f3a0 100644 --- a/src/Umbraco.Web/Search/ExamineComposer.cs +++ b/src/Umbraco.Web/Search/ExamineComposer.cs @@ -48,11 +48,6 @@ namespace Umbraco.Web.Search composition.RegisterUnique, MediaValueSetBuilder>(); composition.RegisterUnique, MemberValueSetBuilder>(); composition.RegisterUnique(); - - //We want to manage Examine's AppDomain shutdown sequence ourselves so first we'll disable Examine's default behavior - //and then we'll use MainDom to control Examine's shutdown - this MUST be done in Compose ie before ExamineManager - //is instantiated, as the value is used during instantiation - ExamineManager.DisableDefaultHostingEnvironmentRegistration(); } } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index f577f212d6..cac8dd0704 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1,4 +1,4 @@ - + @@ -62,7 +62,6 @@ - 2.7.0.100 From 4cf4952a7ee61d448f9b277713062f539a7d1ac5 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2020 15:38:23 +1100 Subject: [PATCH 02/16] Umbraco.Web still needs refs to Examine.Lucene for now. Going to try to split Umbraco.Examine into 2x projects --- src/Umbraco.Web/Umbraco.Web.csproj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index cac8dd0704..72a46481ea 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -62,6 +62,12 @@ + + 2.0.0 + + + 2.0.0 + 2.7.0.100 @@ -107,8 +113,8 @@ Umbraco.Configuration + {07fbc26b-2927-4a22-8d96-d644c667fecc} Umbraco.Examine - {07FBC26B-2927-4A22-8D96-D644C667FECC} {3ae7bf57-966b-45a5-910a-954d7c554441} From 0343b302f35a5949ee150ceb8dc744706ea206d0 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2020 16:37:55 +1100 Subject: [PATCH 03/16] Moving stuff to Examine2 (temp name) as a netstandard project, updates to latest Examine netstandard, moves constants to separate class. --- src/Umbraco.Examine/ContentValueSetBuilder.cs | 10 +++---- .../ContentValueSetValidator.cs | 6 ++-- src/Umbraco.Examine/ExamineExtensions.cs | 1 - src/Umbraco.Examine/MediaValueSetBuilder.cs | 4 +-- src/Umbraco.Examine/Umbraco.Examine.csproj | 30 ++++--------------- src/Umbraco.Examine/UmbracoContentIndex.cs | 4 +-- src/Umbraco.Examine/UmbracoExamineIndex.cs | 22 ++++---------- .../UmbracoFieldDefinitionCollection.cs | 10 +++---- .../BaseValueSetBuilder.cs | 0 .../ContentIndexPopulator.cs | 1 - .../IContentValueSetBuilder.cs | 0 .../IContentValueSetValidator.cs | 0 .../IIndexCreator.cs | 0 .../IIndexDiagnostics.cs | 0 .../IIndexPopulator.cs | 0 .../IPublishedContentValueSetBuilder.cs | 0 .../IUmbracoContentIndex.cs | 0 .../IUmbracoIndex.cs | 0 .../IUmbracoIndexConfig.cs | 0 .../IUmbracoMemberIndex.cs | 0 .../IValueSetBuilder.cs | 0 .../IndexPopulator.cs | 0 .../IndexRebuilder.cs | 0 .../IndexTypes.cs | 0 .../MediaIndexPopulator.cs | 1 - .../MemberIndexPopulator.cs | 1 - .../MemberValueSetBuilder.cs | 2 +- .../MemberValueSetValidator.cs | 2 +- src/Umbraco.Examine2/Umbraco.Examine2.csproj | 16 ++++++++++ .../UmbracoExamineFieldNames.cs | 23 ++++++++++++++ .../ValueSetValidator.cs | 4 +-- .../DictionaryPublishedContent.cs | 6 ++-- .../PublishedMediaCache.cs | 8 ++--- src/Umbraco.Tests/Umbraco.Tests.csproj | 6 +++- src/Umbraco.Tests/UmbracoExamine/IndexTest.cs | 14 ++++----- .../UmbracoContentValueSetValidatorTests.cs | 26 ++++++++-------- .../Web/PublishedContentQueryTests.cs | 6 ++-- src/Umbraco.Web/ExamineExtensions.cs | 2 +- .../Models/Mapping/EntityMapDefinition.cs | 20 ++++++------- .../GridPropertyIndexValueFactory.cs | 2 +- .../PropertyEditors/RichTextPropertyEditor.cs | 2 +- src/Umbraco.Web/PublishedContentExtensions.cs | 2 +- src/Umbraco.Web/PublishedContentQuery.cs | 2 +- src/Umbraco.Web/Search/UmbracoTreeSearcher.cs | 8 ++--- .../Search/UmbracoTreeSearcherFields.cs | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 8 +++-- src/umbraco.sln | 17 +++++++---- 47 files changed, 142 insertions(+), 126 deletions(-) rename src/{Umbraco.Examine => Umbraco.Examine2}/BaseValueSetBuilder.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/ContentIndexPopulator.cs (98%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IContentValueSetBuilder.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IContentValueSetValidator.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IIndexCreator.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IIndexDiagnostics.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IIndexPopulator.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IPublishedContentValueSetBuilder.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IUmbracoContentIndex.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IUmbracoIndex.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IUmbracoIndexConfig.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IUmbracoMemberIndex.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IValueSetBuilder.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IndexPopulator.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IndexRebuilder.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/IndexTypes.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine2}/MediaIndexPopulator.cs (99%) rename src/{Umbraco.Examine => Umbraco.Examine2}/MemberIndexPopulator.cs (98%) rename src/{Umbraco.Examine => Umbraco.Examine2}/MemberValueSetBuilder.cs (95%) rename src/{Umbraco.Examine => Umbraco.Examine2}/MemberValueSetValidator.cs (96%) create mode 100644 src/Umbraco.Examine2/Umbraco.Examine2.csproj create mode 100644 src/Umbraco.Examine2/UmbracoExamineFieldNames.cs rename src/{Umbraco.Examine => Umbraco.Examine2}/ValueSetValidator.cs (97%) diff --git a/src/Umbraco.Examine/ContentValueSetBuilder.cs b/src/Umbraco.Examine/ContentValueSetBuilder.cs index b2f8ae720b..6de7956e65 100644 --- a/src/Umbraco.Examine/ContentValueSetBuilder.cs +++ b/src/Umbraco.Examine/ContentValueSetBuilder.cs @@ -46,9 +46,9 @@ namespace Umbraco.Examine var values = new Dictionary> { {"icon", c.ContentType.Icon?.Yield() ?? Enumerable.Empty()}, - {UmbracoExamineIndex.PublishedFieldName, new object[] {c.Published ? "y" : "n"}}, //Always add invariant published value + {UmbracoExamineFieldNames.PublishedFieldName, new object[] {c.Published ? "y" : "n"}}, //Always add invariant published value {"id", new object[] {c.Id}}, - {UmbracoExamineIndex.NodeKeyFieldName, new object[] {c.Key}}, + {UmbracoExamineFieldNames.NodeKeyFieldName, new object[] {c.Key}}, {"parentID", new object[] {c.Level > 1 ? c.ParentId : -1}}, {"level", new object[] {c.Level}}, {"creatorID", new object[] {c.CreatorId}}, @@ -65,12 +65,12 @@ namespace Umbraco.Examine {"writerName",(c.GetWriterProfile(_userService)?.Name ?? "??").Yield() }, {"writerID", new object[] {c.WriterId}}, {"templateID", new object[] {c.TemplateId ?? 0}}, - {UmbracoContentIndex.VariesByCultureFieldName, new object[] {"n"}}, + {UmbracoExamineFieldNames.VariesByCultureFieldName, new object[] {"n"}}, }; if (isVariant) { - values[UmbracoContentIndex.VariesByCultureFieldName] = new object[] { "y" }; + values[UmbracoExamineFieldNames.VariesByCultureFieldName] = new object[] { "y" }; foreach (var culture in c.AvailableCultures) { @@ -80,7 +80,7 @@ namespace Umbraco.Examine values[$"nodeName_{lowerCulture}"] = (PublishedValuesOnly ? c.GetPublishName(culture)?.Yield() : c.GetCultureName(culture)?.Yield()) ?? Enumerable.Empty(); - values[$"{UmbracoExamineIndex.PublishedFieldName}_{lowerCulture}"] = (c.IsCulturePublished(culture) ? "y" : "n").Yield(); + values[$"{UmbracoExamineFieldNames.PublishedFieldName}_{lowerCulture}"] = (c.IsCulturePublished(culture) ? "y" : "n").Yield(); values[$"updateDate_{lowerCulture}"] = (PublishedValuesOnly ? c.GetPublishDate(culture) : c.GetUpdateDate(culture))?.Yield() ?? Enumerable.Empty(); diff --git a/src/Umbraco.Examine/ContentValueSetValidator.cs b/src/Umbraco.Examine/ContentValueSetValidator.cs index 9555566c53..2c9fdd4752 100644 --- a/src/Umbraco.Examine/ContentValueSetValidator.cs +++ b/src/Umbraco.Examine/ContentValueSetValidator.cs @@ -92,18 +92,18 @@ namespace Umbraco.Examine //check for published content if (valueSet.Category == IndexTypes.Content && PublishedValuesOnly) { - if (!valueSet.Values.TryGetValue(UmbracoExamineIndex.PublishedFieldName, out var published)) + if (!valueSet.Values.TryGetValue(UmbracoExamineFieldNames.PublishedFieldName, out var published)) return ValueSetValidationResult.Failed; if (!published[0].Equals("y")) return ValueSetValidationResult.Failed; //deal with variants, if there are unpublished variants than we need to remove them from the value set - if (valueSet.Values.TryGetValue(UmbracoContentIndex.VariesByCultureFieldName, out var variesByCulture) + if (valueSet.Values.TryGetValue(UmbracoExamineFieldNames.VariesByCultureFieldName, out var variesByCulture) && variesByCulture.Count > 0 && variesByCulture[0].Equals("y")) { //so this valueset is for a content that varies by culture, now check for non-published cultures and remove those values - foreach(var publishField in valueSet.Values.Where(x => x.Key.StartsWith($"{UmbracoExamineIndex.PublishedFieldName}_")).ToList()) + foreach(var publishField in valueSet.Values.Where(x => x.Key.StartsWith($"{UmbracoExamineFieldNames.PublishedFieldName}_")).ToList()) { if (publishField.Value.Count <= 0 || !publishField.Value[0].Equals("y")) { diff --git a/src/Umbraco.Examine/ExamineExtensions.cs b/src/Umbraco.Examine/ExamineExtensions.cs index d231a86f69..027be708e1 100644 --- a/src/Umbraco.Examine/ExamineExtensions.cs +++ b/src/Umbraco.Examine/ExamineExtensions.cs @@ -8,7 +8,6 @@ using Lucene.Net.Analysis; using Lucene.Net.Index; using Lucene.Net.QueryParsers; using Lucene.Net.Search; -using Lucene.Net.Store; using Umbraco.Core; using Version = Lucene.Net.Util.Version; using Umbraco.Core.Logging; diff --git a/src/Umbraco.Examine/MediaValueSetBuilder.cs b/src/Umbraco.Examine/MediaValueSetBuilder.cs index fd77c180dc..356beb3647 100644 --- a/src/Umbraco.Examine/MediaValueSetBuilder.cs +++ b/src/Umbraco.Examine/MediaValueSetBuilder.cs @@ -77,7 +77,7 @@ namespace Umbraco.Examine { {"icon", m.ContentType.Icon?.Yield() ?? Enumerable.Empty()}, {"id", new object[] {m.Id}}, - {UmbracoExamineIndex.NodeKeyFieldName, new object[] {m.Key}}, + {UmbracoExamineFieldNames.NodeKeyFieldName, new object[] {m.Key}}, {"parentID", new object[] {m.Level > 1 ? m.ParentId : -1}}, {"level", new object[] {m.Level}}, {"creatorID", new object[] {m.CreatorId}}, @@ -89,7 +89,7 @@ namespace Umbraco.Examine {"path", m.Path?.Yield() ?? Enumerable.Empty()}, {"nodeType", m.ContentType.Id.ToString().Yield() }, {"creatorName", (m.GetCreatorProfile(_userService)?.Name ?? "??").Yield()}, - {UmbracoExamineIndex.UmbracoFileFieldName, umbracoFile.Yield()} + {UmbracoExamineFieldNames.UmbracoFileFieldName, umbracoFile.Yield()} }; foreach (var property in m.Properties) diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj index 047fb7813e..c79c698a81 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -49,11 +49,8 @@ - - 2.0.0 - - 2.0.0 + 2.0.0-alpha.20200128.15 1.0.0-beta2-19554-01 @@ -69,33 +66,13 @@ - - - - - - - - - - - - - - - - - - - - @@ -108,13 +85,16 @@ Properties\SolutionInfo.cs - {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions + + {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} + Umbraco.Examine2 + {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure diff --git a/src/Umbraco.Examine/UmbracoContentIndex.cs b/src/Umbraco.Examine/UmbracoContentIndex.cs index 33fd2d0ee7..1c8cd4b074 100644 --- a/src/Umbraco.Examine/UmbracoContentIndex.cs +++ b/src/Umbraco.Examine/UmbracoContentIndex.cs @@ -20,7 +20,7 @@ namespace Umbraco.Examine /// public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex { - public const string VariesByCultureFieldName = SpecialFieldPrefix + "VariesByCulture"; + protected ILocalizationService LanguageService { get; } #region Constructors @@ -132,7 +132,7 @@ namespace Umbraco.Examine { //find all descendants based on path var descendantPath = $@"\-1\,*{nodeId}\,*"; - var rawQuery = $"{IndexPathFieldName}:{descendantPath}"; + var rawQuery = $"{UmbracoExamineFieldNames.IndexPathFieldName}:{descendantPath}"; var searcher = GetSearcher(); var c = searcher.CreateQuery(); var filtered = c.NativeQuery(rawQuery); diff --git a/src/Umbraco.Examine/UmbracoExamineIndex.cs b/src/Umbraco.Examine/UmbracoExamineIndex.cs index f7dfcf6375..880440f4f9 100644 --- a/src/Umbraco.Examine/UmbracoExamineIndex.cs +++ b/src/Umbraco.Examine/UmbracoExamineIndex.cs @@ -28,19 +28,7 @@ namespace Umbraco.Examine // call context (and the database it can contain)! ideally we should be able to override // SafelyProcessQueueItems but that's not possible in the current version of Examine. - /// - /// Used to store the path of a content object - /// - public const string IndexPathFieldName = SpecialFieldPrefix + "Path"; - public const string NodeKeyFieldName = SpecialFieldPrefix + "Key"; - public const string UmbracoFileFieldName = "umbracoFileSrc"; - public const string IconFieldName = SpecialFieldPrefix + "Icon"; - public const string PublishedFieldName = SpecialFieldPrefix + "Published"; - - /// - /// The prefix added to a field when it is duplicated in order to store the original raw value. - /// - public const string RawFieldPrefix = SpecialFieldPrefix + "Raw_"; + /// /// Create a new @@ -141,7 +129,7 @@ namespace Umbraco.Examine { var d = docArgs.Document; - foreach (var f in docArgs.ValueSet.Values.Where(x => x.Key.StartsWith(RawFieldPrefix)).ToList()) + foreach (var f in docArgs.ValueSet.Values.Where(x => x.Key.StartsWith(UmbracoExamineFieldNames.RawFieldPrefix)).ToList()) { if (f.Value.Count > 0) { @@ -182,13 +170,13 @@ namespace Umbraco.Examine var path = e.ValueSet.GetValue("path"); if (path != null) { - e.ValueSet.Set(IndexPathFieldName, path); + e.ValueSet.Set(UmbracoExamineFieldNames.IndexPathFieldName, path); } //icon - if (e.ValueSet.Values.TryGetValue("icon", out var icon) && e.ValueSet.Values.ContainsKey(IconFieldName) == false) + if (e.ValueSet.Values.TryGetValue("icon", out var icon) && e.ValueSet.Values.ContainsKey(UmbracoExamineFieldNames.IconFieldName) == false) { - e.ValueSet.Values[IconFieldName] = icon; + e.ValueSet.Values[UmbracoExamineFieldNames.IconFieldName] = icon; } } diff --git a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs index 1e7b51aa14..5633b6a2cc 100644 --- a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs +++ b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs @@ -33,7 +33,7 @@ namespace Umbraco.Examine new FieldDefinition("createDate", FieldDefinitionTypes.DateTime), new FieldDefinition("updateDate", FieldDefinitionTypes.DateTime), - new FieldDefinition(UmbracoExamineIndex.NodeKeyFieldName, FieldDefinitionTypes.InvariantCultureIgnoreCase), + new FieldDefinition(UmbracoExamineFieldNames.NodeKeyFieldName, FieldDefinitionTypes.InvariantCultureIgnoreCase), new FieldDefinition("version", FieldDefinitionTypes.Raw), new FieldDefinition("nodeType", FieldDefinitionTypes.InvariantCultureIgnoreCase), new FieldDefinition("template", FieldDefinitionTypes.Raw), @@ -42,10 +42,10 @@ namespace Umbraco.Examine new FieldDefinition("email", FieldDefinitionTypes.EmailAddress), - new FieldDefinition(UmbracoExamineIndex.PublishedFieldName, FieldDefinitionTypes.Raw), - new FieldDefinition(UmbracoExamineIndex.IndexPathFieldName, FieldDefinitionTypes.Raw), - new FieldDefinition(UmbracoExamineIndex.IconFieldName, FieldDefinitionTypes.Raw), - new FieldDefinition(UmbracoContentIndex.VariesByCultureFieldName, FieldDefinitionTypes.Raw), + new FieldDefinition(UmbracoExamineFieldNames.PublishedFieldName, FieldDefinitionTypes.Raw), + new FieldDefinition(UmbracoExamineFieldNames.IndexPathFieldName, FieldDefinitionTypes.Raw), + new FieldDefinition(UmbracoExamineFieldNames.IconFieldName, FieldDefinitionTypes.Raw), + new FieldDefinition(UmbracoExamineFieldNames.VariesByCultureFieldName, FieldDefinitionTypes.Raw), }; diff --git a/src/Umbraco.Examine/BaseValueSetBuilder.cs b/src/Umbraco.Examine2/BaseValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine/BaseValueSetBuilder.cs rename to src/Umbraco.Examine2/BaseValueSetBuilder.cs diff --git a/src/Umbraco.Examine/ContentIndexPopulator.cs b/src/Umbraco.Examine2/ContentIndexPopulator.cs similarity index 98% rename from src/Umbraco.Examine/ContentIndexPopulator.cs rename to src/Umbraco.Examine2/ContentIndexPopulator.cs index 99ff4d7f87..8b34c3315a 100644 --- a/src/Umbraco.Examine/ContentIndexPopulator.cs +++ b/src/Umbraco.Examine2/ContentIndexPopulator.cs @@ -6,7 +6,6 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Querying; namespace Umbraco.Examine diff --git a/src/Umbraco.Examine/IContentValueSetBuilder.cs b/src/Umbraco.Examine2/IContentValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine/IContentValueSetBuilder.cs rename to src/Umbraco.Examine2/IContentValueSetBuilder.cs diff --git a/src/Umbraco.Examine/IContentValueSetValidator.cs b/src/Umbraco.Examine2/IContentValueSetValidator.cs similarity index 100% rename from src/Umbraco.Examine/IContentValueSetValidator.cs rename to src/Umbraco.Examine2/IContentValueSetValidator.cs diff --git a/src/Umbraco.Examine/IIndexCreator.cs b/src/Umbraco.Examine2/IIndexCreator.cs similarity index 100% rename from src/Umbraco.Examine/IIndexCreator.cs rename to src/Umbraco.Examine2/IIndexCreator.cs diff --git a/src/Umbraco.Examine/IIndexDiagnostics.cs b/src/Umbraco.Examine2/IIndexDiagnostics.cs similarity index 100% rename from src/Umbraco.Examine/IIndexDiagnostics.cs rename to src/Umbraco.Examine2/IIndexDiagnostics.cs diff --git a/src/Umbraco.Examine/IIndexPopulator.cs b/src/Umbraco.Examine2/IIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine/IIndexPopulator.cs rename to src/Umbraco.Examine2/IIndexPopulator.cs diff --git a/src/Umbraco.Examine/IPublishedContentValueSetBuilder.cs b/src/Umbraco.Examine2/IPublishedContentValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine/IPublishedContentValueSetBuilder.cs rename to src/Umbraco.Examine2/IPublishedContentValueSetBuilder.cs diff --git a/src/Umbraco.Examine/IUmbracoContentIndex.cs b/src/Umbraco.Examine2/IUmbracoContentIndex.cs similarity index 100% rename from src/Umbraco.Examine/IUmbracoContentIndex.cs rename to src/Umbraco.Examine2/IUmbracoContentIndex.cs diff --git a/src/Umbraco.Examine/IUmbracoIndex.cs b/src/Umbraco.Examine2/IUmbracoIndex.cs similarity index 100% rename from src/Umbraco.Examine/IUmbracoIndex.cs rename to src/Umbraco.Examine2/IUmbracoIndex.cs diff --git a/src/Umbraco.Examine/IUmbracoIndexConfig.cs b/src/Umbraco.Examine2/IUmbracoIndexConfig.cs similarity index 100% rename from src/Umbraco.Examine/IUmbracoIndexConfig.cs rename to src/Umbraco.Examine2/IUmbracoIndexConfig.cs diff --git a/src/Umbraco.Examine/IUmbracoMemberIndex.cs b/src/Umbraco.Examine2/IUmbracoMemberIndex.cs similarity index 100% rename from src/Umbraco.Examine/IUmbracoMemberIndex.cs rename to src/Umbraco.Examine2/IUmbracoMemberIndex.cs diff --git a/src/Umbraco.Examine/IValueSetBuilder.cs b/src/Umbraco.Examine2/IValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine/IValueSetBuilder.cs rename to src/Umbraco.Examine2/IValueSetBuilder.cs diff --git a/src/Umbraco.Examine/IndexPopulator.cs b/src/Umbraco.Examine2/IndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine/IndexPopulator.cs rename to src/Umbraco.Examine2/IndexPopulator.cs diff --git a/src/Umbraco.Examine/IndexRebuilder.cs b/src/Umbraco.Examine2/IndexRebuilder.cs similarity index 100% rename from src/Umbraco.Examine/IndexRebuilder.cs rename to src/Umbraco.Examine2/IndexRebuilder.cs diff --git a/src/Umbraco.Examine/IndexTypes.cs b/src/Umbraco.Examine2/IndexTypes.cs similarity index 100% rename from src/Umbraco.Examine/IndexTypes.cs rename to src/Umbraco.Examine2/IndexTypes.cs diff --git a/src/Umbraco.Examine/MediaIndexPopulator.cs b/src/Umbraco.Examine2/MediaIndexPopulator.cs similarity index 99% rename from src/Umbraco.Examine/MediaIndexPopulator.cs rename to src/Umbraco.Examine2/MediaIndexPopulator.cs index 1f5b11e54f..03fbe392b6 100644 --- a/src/Umbraco.Examine/MediaIndexPopulator.cs +++ b/src/Umbraco.Examine2/MediaIndexPopulator.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using Examine; -using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; diff --git a/src/Umbraco.Examine/MemberIndexPopulator.cs b/src/Umbraco.Examine2/MemberIndexPopulator.cs similarity index 98% rename from src/Umbraco.Examine/MemberIndexPopulator.cs rename to src/Umbraco.Examine2/MemberIndexPopulator.cs index 26a3b0aedd..270d93d80d 100644 --- a/src/Umbraco.Examine/MemberIndexPopulator.cs +++ b/src/Umbraco.Examine2/MemberIndexPopulator.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using Examine; -using Lucene.Net.Util; using Umbraco.Core.Models; using Umbraco.Core.Services; diff --git a/src/Umbraco.Examine/MemberValueSetBuilder.cs b/src/Umbraco.Examine2/MemberValueSetBuilder.cs similarity index 95% rename from src/Umbraco.Examine/MemberValueSetBuilder.cs rename to src/Umbraco.Examine2/MemberValueSetBuilder.cs index 06fe78105d..94cd838efe 100644 --- a/src/Umbraco.Examine/MemberValueSetBuilder.cs +++ b/src/Umbraco.Examine2/MemberValueSetBuilder.cs @@ -24,7 +24,7 @@ namespace Umbraco.Examine { {"icon", m.ContentType.Icon?.Yield() ?? Enumerable.Empty()}, {"id", new object[] {m.Id}}, - {UmbracoExamineIndex.NodeKeyFieldName, new object[] {m.Key}}, + {UmbracoExamineFieldNames.NodeKeyFieldName, new object[] {m.Key}}, {"parentID", new object[] {m.Level > 1 ? m.ParentId : -1}}, {"level", new object[] {m.Level}}, {"creatorID", new object[] {m.CreatorId}}, diff --git a/src/Umbraco.Examine/MemberValueSetValidator.cs b/src/Umbraco.Examine2/MemberValueSetValidator.cs similarity index 96% rename from src/Umbraco.Examine/MemberValueSetValidator.cs rename to src/Umbraco.Examine2/MemberValueSetValidator.cs index 0c585854e9..876bc84127 100644 --- a/src/Umbraco.Examine/MemberValueSetValidator.cs +++ b/src/Umbraco.Examine2/MemberValueSetValidator.cs @@ -23,7 +23,7 @@ namespace Umbraco.Examine /// /// By default these are the member fields we index /// - public static readonly string[] DefaultMemberIndexFields = { "id", "nodeName", "updateDate", "loginName", "email", UmbracoExamineIndex.NodeKeyFieldName }; + public static readonly string[] DefaultMemberIndexFields = { "id", "nodeName", "updateDate", "loginName", "email", UmbracoExamineFieldNames.NodeKeyFieldName }; private static readonly IEnumerable ValidCategories = new[] { IndexTypes.Member }; protected override IEnumerable ValidIndexCategories => ValidCategories; diff --git a/src/Umbraco.Examine2/Umbraco.Examine2.csproj b/src/Umbraco.Examine2/Umbraco.Examine2.csproj new file mode 100644 index 0000000000..904d4b7107 --- /dev/null +++ b/src/Umbraco.Examine2/Umbraco.Examine2.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs b/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs new file mode 100644 index 0000000000..56eb929f17 --- /dev/null +++ b/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs @@ -0,0 +1,23 @@ +using Examine; + +namespace Umbraco.Examine +{ + public static class UmbracoExamineFieldNames + { + /// + /// Used to store the path of a content object + /// + public const string IndexPathFieldName = ExamineFieldNames.SpecialFieldPrefix + "Path"; + public const string NodeKeyFieldName = ExamineFieldNames.SpecialFieldPrefix + "Key"; + public const string UmbracoFileFieldName = "umbracoFileSrc"; + public const string IconFieldName = ExamineFieldNames.SpecialFieldPrefix + "Icon"; + public const string PublishedFieldName = ExamineFieldNames.SpecialFieldPrefix + "Published"; + + /// + /// The prefix added to a field when it is duplicated in order to store the original raw value. + /// + public const string RawFieldPrefix = ExamineFieldNames.SpecialFieldPrefix + "Raw_"; + + public const string VariesByCultureFieldName = ExamineFieldNames.SpecialFieldPrefix + "VariesByCulture"; + } +} diff --git a/src/Umbraco.Examine/ValueSetValidator.cs b/src/Umbraco.Examine2/ValueSetValidator.cs similarity index 97% rename from src/Umbraco.Examine/ValueSetValidator.cs rename to src/Umbraco.Examine2/ValueSetValidator.cs index 4db251c0f1..f6538dfacd 100644 --- a/src/Umbraco.Examine/ValueSetValidator.cs +++ b/src/Umbraco.Examine2/ValueSetValidator.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Examine; -using Examine.LuceneEngine.Providers; using Umbraco.Core; namespace Umbraco.Examine diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs index 31fbb8d6b9..f873f3a683 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs @@ -1,9 +1,9 @@ -using System; +using Examine; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Xml.XPath; -using Examine.LuceneEngine.Providers; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Logging; @@ -59,7 +59,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache ValidateAndSetProperty(valueDictionary, val => _sortOrder = Int32.Parse(val), "sortOrder"); ValidateAndSetProperty(valueDictionary, val => _name = val, "nodeName"); ValidateAndSetProperty(valueDictionary, val => _urlName = val, "urlName"); - ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", LuceneIndex.ItemTypeFieldName); + ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", ExamineFieldNames.ItemTypeFieldName); ValidateAndSetProperty(valueDictionary, val => _documentTypeId = Int32.Parse(val), "nodeType"); //ValidateAndSetProperty(valueDictionary, val => _writerName = val, "writerName"); ValidateAndSetProperty(valueDictionary, val => _creatorName = val, "creatorName", "writerName"); //this is a bit of a hack fix for: U4-1132 diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs index f913d1c9b8..03c6ddba47 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs @@ -120,7 +120,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache // +(+parentID:-1) +__IndexType:media var criteria = searchProvider.CreateQuery("media"); - var filter = criteria.ParentId(-1).Not().Field(UmbracoExamineIndex.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard()); + var filter = criteria.ParentId(-1).Not().Field(UmbracoExamineFieldNames.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard()); var result = filter.Execute(); if (result != null) @@ -289,7 +289,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache // note that since the use of the wildcard, it automatically escapes it in Lucene. var criteria = searchProvider.CreateQuery("media"); - var filter = criteria.Id(id.ToInvariantString()).Not().Field(UmbracoExamineIndex.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard()); + var filter = criteria.Id(id.ToInvariantString()).Not().Field(UmbracoExamineFieldNames.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard()); var result = filter.Execute().FirstOrDefault(); if (result != null) return ConvertFromSearchResult(result); @@ -471,7 +471,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache { //We are going to check for a special field however, that is because in some cases we store a 'Raw' //value in the index such as for xml/html. - var rawValue = dd.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(UmbracoExamineIndex.RawFieldPrefix + alias)); + var rawValue = dd.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(UmbracoExamineFieldNames.RawFieldPrefix + alias)); return rawValue ?? dd.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(alias)); } @@ -504,7 +504,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache //first check in Examine as this is WAY faster var criteria = searchProvider.CreateQuery("media"); - var filter = criteria.ParentId(parentId).Not().Field(UmbracoExamineIndex.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard()) + var filter = criteria.ParentId(parentId).Not().Field(UmbracoExamineFieldNames.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard()) .OrderBy(new SortableField("sortOrder", SortType.Int)); //the above filter will create a query like this, NOTE: That since the use of the wildcard, it automatically escapes it in Lucene. //+(+parentId:3113 -__Path:-1,-21,*) +__IndexType:media diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 2892e39b49..2ae54d7aa3 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -79,7 +79,7 @@ - 2.0.0 + 2.0.0-alpha.20200128.15 1.8.14 @@ -564,6 +564,10 @@ {fbe7c065-dac0-4025-a78b-63b24d3ab00b} Umbraco.Configuration + + {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} + Umbraco.Examine2 + {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs index e41169c6ec..e6fe5170e4 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs @@ -114,8 +114,8 @@ namespace Umbraco.Tests.UmbracoExamine Assert.AreEqual("value2", result.AllValues["grid.row1"][1]); Assert.IsTrue(result.Values.ContainsKey("grid")); Assert.AreEqual("value1 value2 ", result["grid"]); - Assert.IsTrue(result.Values.ContainsKey($"{UmbracoExamineIndex.RawFieldPrefix}grid")); - Assert.AreEqual(json, result[$"{UmbracoExamineIndex.RawFieldPrefix}grid"]); + Assert.IsTrue(result.Values.ContainsKey($"{UmbracoExamineFieldNames.RawFieldPrefix}grid")); + Assert.AreEqual(json, result[$"{UmbracoExamineFieldNames.RawFieldPrefix}grid"]); } } @@ -165,12 +165,12 @@ namespace Umbraco.Tests.UmbracoExamine var protectedQuery = new BooleanQuery(); protectedQuery.Add( new BooleanClause( - new TermQuery(new Term(LuceneIndex.CategoryFieldName, IndexTypes.Content)), + new TermQuery(new Term(ExamineFieldNames.CategoryFieldName, IndexTypes.Content)), Occur.MUST)); protectedQuery.Add( new BooleanClause( - new TermQuery(new Term(LuceneIndex.ItemIdFieldName, ExamineDemoDataContentService.ProtectedNode.ToString())), + new TermQuery(new Term(ExamineFieldNames.ItemIdFieldName, ExamineDemoDataContentService.ProtectedNode.ToString())), Occur.MUST)); var collector = TopScoreDocCollector.Create(100, true); @@ -287,7 +287,7 @@ namespace Umbraco.Tests.UmbracoExamine //create the whole thing rebuilder.Populate(indexer); - var result = searcher.CreateQuery().Field(LuceneIndex.CategoryFieldName, IndexTypes.Content).Execute(); + var result = searcher.CreateQuery().Field(ExamineFieldNames.CategoryFieldName, IndexTypes.Content).Execute(); Assert.AreEqual(21, result.TotalItemCount); //delete all content @@ -298,13 +298,13 @@ namespace Umbraco.Tests.UmbracoExamine //ensure it's all gone - result = searcher.CreateQuery().Field(LuceneIndex.CategoryFieldName, IndexTypes.Content).Execute(); + result = searcher.CreateQuery().Field(ExamineFieldNames.CategoryFieldName, IndexTypes.Content).Execute(); Assert.AreEqual(0, result.TotalItemCount); //call our indexing methods rebuilder.Populate(indexer); - result = searcher.CreateQuery().Field(LuceneIndex.CategoryFieldName, IndexTypes.Content).Execute(); + result = searcher.CreateQuery().Field(ExamineFieldNames.CategoryFieldName, IndexTypes.Content).Execute(); Assert.AreEqual(21, result.TotalItemCount); } } diff --git a/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs b/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs index 8bdb0c71c7..643c56250d 100644 --- a/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs +++ b/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs @@ -179,7 +179,7 @@ namespace Umbraco.Tests.UmbracoExamine { ["hello"] = "world", ["path"] = "-1,555", - [UmbracoExamineIndex.PublishedFieldName] = "y" + [UmbracoExamineFieldNames.PublishedFieldName] = "y" })); Assert.AreEqual(ValueSetValidationResult.Valid, result); } @@ -213,7 +213,7 @@ namespace Umbraco.Tests.UmbracoExamine { ["hello"] = "world", ["path"] = "-1,555", - [UmbracoExamineIndex.PublishedFieldName] = "n" + [UmbracoExamineFieldNames.PublishedFieldName] = "n" })); Assert.AreEqual(ValueSetValidationResult.Failed, result); @@ -222,7 +222,7 @@ namespace Umbraco.Tests.UmbracoExamine { ["hello"] = "world", ["path"] = "-1,555", - [UmbracoExamineIndex.PublishedFieldName] = "y" + [UmbracoExamineFieldNames.PublishedFieldName] = "y" })); Assert.AreEqual(ValueSetValidationResult.Valid, result); } @@ -237,8 +237,8 @@ namespace Umbraco.Tests.UmbracoExamine { ["hello"] = "world", ["path"] = "-1,555", - [UmbracoContentIndex.VariesByCultureFieldName] = "y", - [UmbracoExamineIndex.PublishedFieldName] = "n" + [UmbracoExamineFieldNames.VariesByCultureFieldName] = "y", + [UmbracoExamineFieldNames.PublishedFieldName] = "n" })); Assert.AreEqual(ValueSetValidationResult.Failed, result); @@ -247,8 +247,8 @@ namespace Umbraco.Tests.UmbracoExamine { ["hello"] = "world", ["path"] = "-1,555", - [UmbracoContentIndex.VariesByCultureFieldName] = "y", - [UmbracoExamineIndex.PublishedFieldName] = "y" + [UmbracoExamineFieldNames.VariesByCultureFieldName] = "y", + [UmbracoExamineFieldNames.PublishedFieldName] = "y" })); Assert.AreEqual(ValueSetValidationResult.Valid, result); @@ -257,17 +257,17 @@ namespace Umbraco.Tests.UmbracoExamine { ["hello"] = "world", ["path"] = "-1,555", - [UmbracoContentIndex.VariesByCultureFieldName] = "y", - [$"{UmbracoExamineIndex.PublishedFieldName}_en-us"] = "y", + [UmbracoExamineFieldNames.VariesByCultureFieldName] = "y", + [$"{UmbracoExamineFieldNames.PublishedFieldName}_en-us"] = "y", ["hello_en-us"] = "world", ["title_en-us"] = "my title", - [$"{UmbracoExamineIndex.PublishedFieldName}_es-es"] = "n", + [$"{UmbracoExamineFieldNames.PublishedFieldName}_es-es"] = "n", ["hello_es-ES"] = "world", ["title_es-ES"] = "my title", - [UmbracoExamineIndex.PublishedFieldName] = "y" + [UmbracoExamineFieldNames.PublishedFieldName] = "y" }); Assert.AreEqual(10, valueSet.Values.Count()); - Assert.IsTrue(valueSet.Values.ContainsKey($"{UmbracoExamineIndex.PublishedFieldName}_es-es")); + Assert.IsTrue(valueSet.Values.ContainsKey($"{UmbracoExamineFieldNames.PublishedFieldName}_es-es")); Assert.IsTrue(valueSet.Values.ContainsKey("hello_es-ES")); Assert.IsTrue(valueSet.Values.ContainsKey("title_es-ES")); @@ -275,7 +275,7 @@ namespace Umbraco.Tests.UmbracoExamine Assert.AreEqual(ValueSetValidationResult.Filtered, result); Assert.AreEqual(7, valueSet.Values.Count()); //filtered to 7 values (removes es-es values) - Assert.IsFalse(valueSet.Values.ContainsKey($"{UmbracoExamineIndex.PublishedFieldName}_es-es")); + Assert.IsFalse(valueSet.Values.ContainsKey($"{UmbracoExamineFieldNames.PublishedFieldName}_es-es")); Assert.IsFalse(valueSet.Values.ContainsKey("hello_es-ES")); Assert.IsFalse(valueSet.Values.ContainsKey("title_es-ES")); } diff --git a/src/Umbraco.Tests/Web/PublishedContentQueryTests.cs b/src/Umbraco.Tests/Web/PublishedContentQueryTests.cs index a3505aeb0e..74ab279fb8 100644 --- a/src/Umbraco.Tests/Web/PublishedContentQueryTests.cs +++ b/src/Umbraco.Tests/Web/PublishedContentQueryTests.cs @@ -42,17 +42,17 @@ namespace Umbraco.Tests.Web indexer.IndexItem(new ValueSet("1", "content", new Dictionary { [fieldNames[0]] = "Hello world, there are products here", - [UmbracoContentIndex.VariesByCultureFieldName] = "n" + [UmbracoExamineFieldNames.VariesByCultureFieldName] = "n" })); indexer.IndexItem(new ValueSet("2", "content", new Dictionary { [fieldNames[1]] = "Hello world, there are products here", - [UmbracoContentIndex.VariesByCultureFieldName] = "y" + [UmbracoExamineFieldNames.VariesByCultureFieldName] = "y" })); indexer.IndexItem(new ValueSet("3", "content", new Dictionary { [fieldNames[2]] = "Hello world, there are products here", - [UmbracoContentIndex.VariesByCultureFieldName] = "y" + [UmbracoExamineFieldNames.VariesByCultureFieldName] = "y" })); } diff --git a/src/Umbraco.Web/ExamineExtensions.cs b/src/Umbraco.Web/ExamineExtensions.cs index 421993f8fd..dd1277d3e2 100644 --- a/src/Umbraco.Web/ExamineExtensions.cs +++ b/src/Umbraco.Web/ExamineExtensions.cs @@ -65,7 +65,7 @@ namespace Umbraco.Web foreach (var result in results) { if (int.TryParse(result.Id, out var contentId) && - result.Values.TryGetValue(LuceneIndex.CategoryFieldName, out var indexType)) + result.Values.TryGetValue(ExamineFieldNames.CategoryFieldName, out var indexType)) { IPublishedContent content; switch (indexType) diff --git a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs index 34b8f664f3..0697504e2a 100644 --- a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs +++ b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs @@ -171,13 +171,13 @@ namespace Umbraco.Web.Models.Mapping // TODO: Properly map this (not aftermap) //get the icon if there is one - target.Icon = source.Values.ContainsKey(UmbracoExamineIndex.IconFieldName) - ? source.Values[UmbracoExamineIndex.IconFieldName] + target.Icon = source.Values.ContainsKey(UmbracoExamineFieldNames.IconFieldName) + ? source.Values[UmbracoExamineFieldNames.IconFieldName] : Constants.Icons.DefaultIcon; target.Name = source.Values.ContainsKey("nodeName") ? source.Values["nodeName"] : "[no name]"; - if (source.Values.TryGetValue(UmbracoExamineIndex.UmbracoFileFieldName, out var umbracoFile)) + if (source.Values.TryGetValue(UmbracoExamineFieldNames.UmbracoFileFieldName, out var umbracoFile)) { if (umbracoFile != null) { @@ -185,16 +185,16 @@ namespace Umbraco.Web.Models.Mapping } } - if (source.Values.ContainsKey(UmbracoExamineIndex.NodeKeyFieldName)) + if (source.Values.ContainsKey(UmbracoExamineFieldNames.NodeKeyFieldName)) { - if (Guid.TryParse(source.Values[UmbracoExamineIndex.NodeKeyFieldName], out var key)) + if (Guid.TryParse(source.Values[UmbracoExamineFieldNames.NodeKeyFieldName], out var key)) { target.Key = key; //need to set the UDI - if (source.Values.ContainsKey(LuceneIndex.CategoryFieldName)) + if (source.Values.ContainsKey(ExamineFieldNames.CategoryFieldName)) { - switch (source.Values[LuceneIndex.CategoryFieldName]) + switch (source.Values[ExamineFieldNames.CategoryFieldName]) { case IndexTypes.Member: target.Udi = new GuidUdi(Constants.UdiEntityType.Member, target.Key); @@ -222,11 +222,11 @@ namespace Umbraco.Web.Models.Mapping } } - target.Path = source.Values.ContainsKey(UmbracoExamineIndex.IndexPathFieldName) ? source.Values[UmbracoExamineIndex.IndexPathFieldName] : ""; + target.Path = source.Values.ContainsKey(UmbracoExamineFieldNames.IndexPathFieldName) ? source.Values[UmbracoExamineFieldNames.IndexPathFieldName] : ""; - if (source.Values.ContainsKey(LuceneIndex.ItemTypeFieldName)) + if (source.Values.ContainsKey(ExamineFieldNames.ItemTypeFieldName)) { - target.AdditionalData.Add("contentType", source.Values[LuceneIndex.ItemTypeFieldName]); + target.AdditionalData.Add("contentType", source.Values[ExamineFieldNames.ItemTypeFieldName]); } } diff --git a/src/Umbraco.Web/PropertyEditors/GridPropertyIndexValueFactory.cs b/src/Umbraco.Web/PropertyEditors/GridPropertyIndexValueFactory.cs index af72f0b819..00afcf19cc 100644 --- a/src/Umbraco.Web/PropertyEditors/GridPropertyIndexValueFactory.cs +++ b/src/Umbraco.Web/PropertyEditors/GridPropertyIndexValueFactory.cs @@ -63,7 +63,7 @@ namespace Umbraco.Web.PropertyEditors } //First save the raw value to a raw field - result.Add(new KeyValuePair>($"{UmbracoExamineIndex.RawFieldPrefix}{property.Alias}", new[] { rawVal })); + result.Add(new KeyValuePair>($"{UmbracoExamineFieldNames.RawFieldPrefix}{property.Alias}", new[] { rawVal })); if (sb.Length > 0) { diff --git a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs index 0a6ef88781..7cf9e3a6d9 100644 --- a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs @@ -185,7 +185,7 @@ namespace Umbraco.Web.PropertyEditors //index the stripped HTML values yield return new KeyValuePair>(property.Alias, new object[] { strVal.StripHtml() }); //store the raw value - yield return new KeyValuePair>($"{UmbracoExamineIndex.RawFieldPrefix}{property.Alias}", new object[] { strVal }); + yield return new KeyValuePair>($"{UmbracoExamineFieldNames.RawFieldPrefix}{property.Alias}", new object[] { strVal }); } } } diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 223b7dbaf1..5466c4a86e 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -208,7 +208,7 @@ namespace Umbraco.Web //var luceneQuery = "+__Path:(" + content.Path.Replace("-", "\\-") + "*) +" + t; var query = searcher.CreateQuery() - .Field(UmbracoExamineIndex.IndexPathFieldName, (content.Path + ",").MultipleCharacterWildcard()) + .Field(UmbracoExamineFieldNames.IndexPathFieldName, (content.Path + ",").MultipleCharacterWildcard()) .And() .ManagedQuery(term); diff --git a/src/Umbraco.Web/PublishedContentQuery.cs b/src/Umbraco.Web/PublishedContentQuery.cs index cf145f8d44..f35cea085d 100644 --- a/src/Umbraco.Web/PublishedContentQuery.cs +++ b/src/Umbraco.Web/PublishedContentQuery.cs @@ -216,7 +216,7 @@ namespace Umbraco.Web else if (string.IsNullOrWhiteSpace(culture)) { // Only search invariant - queryExecutor = query.Field(UmbracoContentIndex.VariesByCultureFieldName, "n") // Must not vary by culture + queryExecutor = query.Field(UmbracoExamineFieldNames.VariesByCultureFieldName, "n") // Must not vary by culture .And().ManagedQuery(term); } else diff --git a/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs b/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs index f9ef0f0a31..306d4c0593 100644 --- a/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs +++ b/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs @@ -242,7 +242,7 @@ namespace Umbraco.Web.Search var queryWordsReplaced = new string[querywords.Length]; // when searching file names containing hyphens we need to replace the hyphens with spaces - if (f.Equals(UmbracoExamineIndex.UmbracoFileFieldName)) + if (f.Equals(UmbracoExamineFieldNames.UmbracoFileFieldName)) { for (var index = 0; index < querywords.Length; index++) { @@ -418,9 +418,9 @@ namespace Umbraco.Web.Search { m.AdditionalData["Email"] = result.Values["email"]; } - if (result.Values.ContainsKey(UmbracoExamineIndex.NodeKeyFieldName) && result.Values[UmbracoExamineIndex.NodeKeyFieldName] != null) + if (result.Values.ContainsKey(UmbracoExamineFieldNames.NodeKeyFieldName) && result.Values[UmbracoExamineFieldNames.NodeKeyFieldName] != null) { - if (Guid.TryParse(result.Values[UmbracoExamineIndex.NodeKeyFieldName], out var key)) + if (Guid.TryParse(result.Values[UmbracoExamineFieldNames.NodeKeyFieldName], out var key)) { m.Key = key; } @@ -455,7 +455,7 @@ namespace Umbraco.Web.Search if (intId.Success) { //if it varies by culture, return the default language URL - if (result.Values.TryGetValue(UmbracoContentIndex.VariesByCultureFieldName, out var varies) && varies == "y") + if (result.Values.TryGetValue(UmbracoExamineFieldNames.VariesByCultureFieldName, out var varies) && varies == "y") { entity.AdditionalData["Url"] = _umbracoContext.Url(intId.Result, defaultLang); } diff --git a/src/Umbraco.Web/Search/UmbracoTreeSearcherFields.cs b/src/Umbraco.Web/Search/UmbracoTreeSearcherFields.cs index f90d7bc6b6..a1c9936542 100644 --- a/src/Umbraco.Web/Search/UmbracoTreeSearcherFields.cs +++ b/src/Umbraco.Web/Search/UmbracoTreeSearcherFields.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.Search { return _backOfficeMembersFields; } - private IReadOnlyList _backOfficeMediaFields = new List {UmbracoExamineIndex.UmbracoFileFieldName }; + private IReadOnlyList _backOfficeMediaFields = new List { UmbracoExamineFieldNames.UmbracoFileFieldName }; public IEnumerable GetBackOfficeMediaFields() { return _backOfficeMediaFields; diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 72a46481ea..8c73da3db8 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -63,10 +63,10 @@ - 2.0.0 + 2.0.0-alpha.20200128.15 - 2.0.0 + 2.0.0-alpha.20200128.15 @@ -112,6 +112,10 @@ {fbe7c065-dac0-4025-a78b-63b24d3ab00b} Umbraco.Configuration + + {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} + Umbraco.Examine2 + {07fbc26b-2927-4a22-8d96-d644c667fecc} Umbraco.Examine diff --git a/src/umbraco.sln b/src/umbraco.sln index 0e060fb4d3..72c713c64f 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -1,4 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29209.152 MinimumVisualStudioVersion = 10.0.40219.1 @@ -100,18 +101,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IssueTemplates", "IssueTemp ..\.github\ISSUE_TEMPLATE\5_Security_issue.md = ..\.github\ISSUE_TEMPLATE\5_Security_issue.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Abstractions", "Umbraco.Abstractions\Umbraco.Abstractions.csproj", "{29AA69D9-B597-4395-8D42-43B1263C240A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Abstractions", "Umbraco.Abstractions\Umbraco.Abstractions.csproj", "{29AA69D9-B597-4395-8D42-43B1263C240A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.ModelsBuilder.Embedded", "Umbraco.ModelsBuilder.Embedded\Umbraco.ModelsBuilder.Embedded.csproj", "{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastructure", "Umbraco.Infrastructure\Umbraco.Infrastructure.csproj", "{3AE7BF57-966B-45A5-910A-954D7C554441}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastructure", "Umbraco.Infrastructure\Umbraco.Infrastructure.csproj", "{3AE7BF57-966B-45A5-910A-954D7C554441}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Configuration", "Umbraco.Configuration\Umbraco.Configuration.csproj", "{FBE7C065-DAC0-4025-A78B-63B24D3AB00B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Configuration", "Umbraco.Configuration\Umbraco.Configuration.csproj", "{FBE7C065-DAC0-4025-A78B-63B24D3AB00B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastrucure.Persistance.SqlCe", "Umbraco.Infrastrucure.Persistance.SqlCe\Umbraco.Infrastrucure.Persistance.SqlCe.csproj", "{33085570-9BF2-4065-A9B0-A29D920D13BA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastrucure.Persistance.SqlCe", "Umbraco.Infrastrucure.Persistance.SqlCe\Umbraco.Infrastrucure.Persistance.SqlCe.csproj", "{33085570-9BF2-4065-A9B0-A29D920D13BA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine2", "Umbraco.Examine2\Umbraco.Examine2.csproj", "{F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -164,6 +167,10 @@ Global {FB5676ED-7A69-492C-B802-E7B24144C0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB5676ED-7A69-492C-B802-E7B24144C0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB5676ED-7A69-492C-B802-E7B24144C0FC}.Release|Any CPU.Build.0 = Release|Any CPU + {F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 0695d308c2665b5f38f73abdbe94338e2672e2b4 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2020 17:07:06 +1100 Subject: [PATCH 04/16] Moves remaining non-lucene stuff --- src/Umbraco.Examine/ExamineExtensions.cs | 55 +------- src/Umbraco.Examine/Umbraco.Examine.csproj | 6 - .../UmbracoExamineExtensions.cs | 66 +-------- .../ContentValueSetBuilder.cs | 2 +- .../ContentValueSetValidator.cs | 5 +- .../MediaValueSetBuilder.cs | 10 +- src/Umbraco.Examine2/MemberValueSetBuilder.cs | 2 +- .../MemberValueSetValidator.cs | 2 +- .../PublishedContentIndexPopulator.cs | 0 src/Umbraco.Examine2/Umbraco.Examine2.csproj | 2 + .../UmbracoExamineExtensions.cs | 133 ++++++++++++++++++ .../UmbracoExamineFieldNames.cs | 2 + .../UmbracoFieldDefinitionCollection.cs | 2 +- .../UmbracoIndexConfig.cs | 0 src/Umbraco.Tests/TestHelpers/TestHelper.cs | 2 + .../UmbracoExamine/IndexInitializer.cs | 10 +- .../UmbracoExamine/SearchTests.cs | 4 +- .../Editors/ExamineManagementController.cs | 2 +- .../Models/Mapping/EntityMapDefinition.cs | 2 +- 19 files changed, 162 insertions(+), 145 deletions(-) rename src/{Umbraco.Examine => Umbraco.Examine2}/ContentValueSetBuilder.cs (97%) rename src/{Umbraco.Examine => Umbraco.Examine2}/ContentValueSetValidator.cs (98%) rename src/{Umbraco.Examine => Umbraco.Examine2}/MediaValueSetBuilder.cs (91%) rename src/{Umbraco.Examine => Umbraco.Examine2}/PublishedContentIndexPopulator.cs (100%) create mode 100644 src/Umbraco.Examine2/UmbracoExamineExtensions.cs rename src/{Umbraco.Examine => Umbraco.Examine2}/UmbracoFieldDefinitionCollection.cs (97%) rename src/{Umbraco.Examine => Umbraco.Examine2}/UmbracoIndexConfig.cs (100%) diff --git a/src/Umbraco.Examine/ExamineExtensions.cs b/src/Umbraco.Examine/ExamineExtensions.cs index 027be708e1..2b763305c2 100644 --- a/src/Umbraco.Examine/ExamineExtensions.cs +++ b/src/Umbraco.Examine/ExamineExtensions.cs @@ -20,13 +20,7 @@ namespace Umbraco.Examine /// public static class ExamineExtensions { - /// - /// Matches a culture iso name suffix - /// - /// - /// myFieldName_en-us will match the "en-us" - /// - internal static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^([_\\w]+)_([a-z]{2}-[a-z0-9]{2,4})$", RegexOptions.Compiled); + private static bool _isConfigured = false; private static object _configuredInit = null; @@ -51,51 +45,6 @@ namespace Umbraco.Examine }); } - //TODO: We need a public method here to just match a field name against CultureIsoCodeFieldNameMatchExpression - - /// - /// Returns all index fields that are culture specific (suffixed) - /// - /// - /// - /// - public static IEnumerable GetCultureFields(this IUmbracoIndex index, string culture) - { - var allFields = index.GetFields(); - // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var field in allFields) - { - var match = CultureIsoCodeFieldNameMatchExpression.Match(field); - if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value)) - yield return field; - } - } - - /// - /// Returns all index fields that are culture specific (suffixed) or invariant - /// - /// - /// - /// - public static IEnumerable GetCultureAndInvariantFields(this IUmbracoIndex index, string culture) - { - var allFields = index.GetFields(); - // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var field in allFields) - { - var match = CultureIsoCodeFieldNameMatchExpression.Match(field); - if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value)) - { - yield return field; //matches this culture field - } - else if (!match.Success) - { - yield return field; //matches no culture field (invariant) - } - - } - } - internal static bool TryParseLuceneQuery(string query) { // TODO: I'd assume there would be a more strict way to parse the query but not that i can find yet, for now we'll @@ -106,7 +55,7 @@ namespace Umbraco.Examine try { //This will pass with a plain old string without any fields, need to figure out a way to have it properly parse - var parsed = new QueryParser(Version.LUCENE_30, "nodeName", new KeywordAnalyzer()).Parse(query); + var parsed = new QueryParser(Version.LUCENE_30, UmbracoExamineFieldNames.NodeNameFieldName, new KeywordAnalyzer()).Parse(query); return true; } catch (ParseException) diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj index c79c698a81..b9ae6a0dcf 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -66,21 +66,15 @@ - - - - - - Properties\SolutionInfo.cs diff --git a/src/Umbraco.Examine/UmbracoExamineExtensions.cs b/src/Umbraco.Examine/UmbracoExamineExtensions.cs index f33b7587e0..7de6dbed9c 100644 --- a/src/Umbraco.Examine/UmbracoExamineExtensions.cs +++ b/src/Umbraco.Examine/UmbracoExamineExtensions.cs @@ -6,71 +6,7 @@ namespace Umbraco.Examine { public static class UmbracoExamineExtensions { - public static IBooleanOperation Id(this IQuery query, int id) - { - var fieldQuery = query.Id(id.ToInvariantString()); - return fieldQuery; - } - - /// - /// Query method to search on parent id - /// - /// - /// - /// - public static IBooleanOperation ParentId(this IQuery query, int id) - { - var fieldQuery = query.Field("parentID", id); - return fieldQuery; - } - - /// - /// Query method to search on node name - /// - /// - /// - /// - public static IBooleanOperation NodeName(this IQuery query, string nodeName) - { - var fieldQuery = query.Field("nodeName", (IExamineValue)new ExamineValue(Examineness.Explicit, nodeName)); - return fieldQuery; - } - - /// - /// Query method to search on node name - /// - /// - /// - /// - public static IBooleanOperation NodeName(this IQuery query, IExamineValue nodeName) - { - var fieldQuery = query.Field("nodeName", nodeName); - return fieldQuery; - } - - /// - /// Query method to search on node type alias - /// - /// - /// - /// - public static IBooleanOperation NodeTypeAlias(this IQuery query, string nodeTypeAlias) - { - var fieldQuery = query.Field("__NodeTypeAlias", (IExamineValue)new ExamineValue(Examineness.Explicit, nodeTypeAlias)); - return fieldQuery; - } - - /// - /// Query method to search on node type alias - /// - /// - /// - /// - public static IBooleanOperation NodeTypeAlias(this IQuery query, IExamineValue nodeTypeAlias) - { - var fieldQuery = query.Field("__NodeTypeAlias", nodeTypeAlias); - return fieldQuery; - } + } diff --git a/src/Umbraco.Examine/ContentValueSetBuilder.cs b/src/Umbraco.Examine2/ContentValueSetBuilder.cs similarity index 97% rename from src/Umbraco.Examine/ContentValueSetBuilder.cs rename to src/Umbraco.Examine2/ContentValueSetBuilder.cs index 6de7956e65..c115939b7d 100644 --- a/src/Umbraco.Examine/ContentValueSetBuilder.cs +++ b/src/Umbraco.Examine2/ContentValueSetBuilder.cs @@ -55,7 +55,7 @@ namespace Umbraco.Examine {"sortOrder", new object[] {c.SortOrder}}, {"createDate", new object[] {c.CreateDate}}, //Always add invariant createDate {"updateDate", new object[] {c.UpdateDate}}, //Always add invariant updateDate - {"nodeName", (PublishedValuesOnly //Always add invariant nodeName + {UmbracoExamineFieldNames.NodeNameFieldName, (PublishedValuesOnly //Always add invariant nodeName ? c.PublishName?.Yield() : c.Name?.Yield()) ?? Enumerable.Empty()}, {"urlName", urlValue?.Yield() ?? Enumerable.Empty()}, //Always add invariant urlName diff --git a/src/Umbraco.Examine/ContentValueSetValidator.cs b/src/Umbraco.Examine2/ContentValueSetValidator.cs similarity index 98% rename from src/Umbraco.Examine/ContentValueSetValidator.cs rename to src/Umbraco.Examine2/ContentValueSetValidator.cs index 2c9fdd4752..24c9ab2c84 100644 --- a/src/Umbraco.Examine/ContentValueSetValidator.cs +++ b/src/Umbraco.Examine2/ContentValueSetValidator.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Examine; -using Examine.LuceneEngine.Providers; using Umbraco.Core; -using Umbraco.Core.Models; using Umbraco.Core.Services; namespace Umbraco.Examine diff --git a/src/Umbraco.Examine/MediaValueSetBuilder.cs b/src/Umbraco.Examine2/MediaValueSetBuilder.cs similarity index 91% rename from src/Umbraco.Examine/MediaValueSetBuilder.cs rename to src/Umbraco.Examine2/MediaValueSetBuilder.cs index 356beb3647..e9aa87a25c 100644 --- a/src/Umbraco.Examine/MediaValueSetBuilder.cs +++ b/src/Umbraco.Examine2/MediaValueSetBuilder.cs @@ -2,7 +2,6 @@ using Examine; using System.Collections.Generic; using System.Linq; -using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; @@ -10,6 +9,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Core.Services; using Umbraco.Core.Strings; +using Umbraco.Core.Serialization; namespace Umbraco.Examine { @@ -19,16 +19,18 @@ namespace Umbraco.Examine private readonly IUserService _userService; private readonly ILogger _logger; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _serializer; public MediaValueSetBuilder(PropertyEditorCollection propertyEditors, UrlSegmentProviderCollection urlSegmentProviders, - IUserService userService, ILogger logger, IShortStringHelper shortStringHelper) + IUserService userService, ILogger logger, IShortStringHelper shortStringHelper, IJsonSerializer serializer) : base(propertyEditors, false) { _urlSegmentProviders = urlSegmentProviders; _userService = userService; _logger = logger; _shortStringHelper = shortStringHelper; + _serializer = serializer; } /// @@ -48,7 +50,7 @@ namespace Umbraco.Examine ImageCropperValue cropper = null; try { - cropper = JsonConvert.DeserializeObject( + cropper = _serializer.Deserialize( m.GetValue(Constants.Conventions.Media.File)); } catch (Exception ex) @@ -84,7 +86,7 @@ namespace Umbraco.Examine {"sortOrder", new object[] {m.SortOrder}}, {"createDate", new object[] {m.CreateDate}}, {"updateDate", new object[] {m.UpdateDate}}, - {"nodeName", m.Name?.Yield() ?? Enumerable.Empty()}, + {UmbracoExamineFieldNames.NodeNameFieldName, m.Name?.Yield() ?? Enumerable.Empty()}, {"urlName", urlValue?.Yield() ?? Enumerable.Empty()}, {"path", m.Path?.Yield() ?? Enumerable.Empty()}, {"nodeType", m.ContentType.Id.ToString().Yield() }, diff --git a/src/Umbraco.Examine2/MemberValueSetBuilder.cs b/src/Umbraco.Examine2/MemberValueSetBuilder.cs index 94cd838efe..12d886eaf1 100644 --- a/src/Umbraco.Examine2/MemberValueSetBuilder.cs +++ b/src/Umbraco.Examine2/MemberValueSetBuilder.cs @@ -31,7 +31,7 @@ namespace Umbraco.Examine {"sortOrder", new object[] {m.SortOrder}}, {"createDate", new object[] {m.CreateDate}}, {"updateDate", new object[] {m.UpdateDate}}, - {"nodeName", m.Name?.Yield() ?? Enumerable.Empty()}, + {UmbracoExamineFieldNames.NodeNameFieldName, m.Name?.Yield() ?? Enumerable.Empty()}, {"path", m.Path?.Yield() ?? Enumerable.Empty()}, {"nodeType", m.ContentType.Id.ToString().Yield() }, {"loginName", m.Username?.Yield() ?? Enumerable.Empty()}, diff --git a/src/Umbraco.Examine2/MemberValueSetValidator.cs b/src/Umbraco.Examine2/MemberValueSetValidator.cs index 876bc84127..6ce650fc1d 100644 --- a/src/Umbraco.Examine2/MemberValueSetValidator.cs +++ b/src/Umbraco.Examine2/MemberValueSetValidator.cs @@ -23,7 +23,7 @@ namespace Umbraco.Examine /// /// By default these are the member fields we index /// - public static readonly string[] DefaultMemberIndexFields = { "id", "nodeName", "updateDate", "loginName", "email", UmbracoExamineFieldNames.NodeKeyFieldName }; + public static readonly string[] DefaultMemberIndexFields = { "id", UmbracoExamineFieldNames.NodeNameFieldName, "updateDate", "loginName", "email", UmbracoExamineFieldNames.NodeKeyFieldName }; private static readonly IEnumerable ValidCategories = new[] { IndexTypes.Member }; protected override IEnumerable ValidIndexCategories => ValidCategories; diff --git a/src/Umbraco.Examine/PublishedContentIndexPopulator.cs b/src/Umbraco.Examine2/PublishedContentIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine/PublishedContentIndexPopulator.cs rename to src/Umbraco.Examine2/PublishedContentIndexPopulator.cs diff --git a/src/Umbraco.Examine2/Umbraco.Examine2.csproj b/src/Umbraco.Examine2/Umbraco.Examine2.csproj index 904d4b7107..e994fcfa47 100644 --- a/src/Umbraco.Examine2/Umbraco.Examine2.csproj +++ b/src/Umbraco.Examine2/Umbraco.Examine2.csproj @@ -2,6 +2,8 @@ netstandard2.0 + Umbraco.Examine2 + Umbraco.Examine diff --git a/src/Umbraco.Examine2/UmbracoExamineExtensions.cs b/src/Umbraco.Examine2/UmbracoExamineExtensions.cs new file mode 100644 index 0000000000..c1932e0514 --- /dev/null +++ b/src/Umbraco.Examine2/UmbracoExamineExtensions.cs @@ -0,0 +1,133 @@ +using Examine; +using Examine.Search; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using Umbraco.Core; + +namespace Umbraco.Examine +{ + public static class UmbracoExamineExtensions + { + /// + /// Matches a culture iso name suffix + /// + /// + /// myFieldName_en-us will match the "en-us" + /// + internal static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^([_\\w]+)_([a-z]{2}-[a-z0-9]{2,4})$", RegexOptions.Compiled); + + + + //TODO: We need a public method here to just match a field name against CultureIsoCodeFieldNameMatchExpression + + /// + /// Returns all index fields that are culture specific (suffixed) + /// + /// + /// + /// + public static IEnumerable GetCultureFields(this IUmbracoIndex index, string culture) + { + var allFields = index.GetFields(); + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (var field in allFields) + { + var match = CultureIsoCodeFieldNameMatchExpression.Match(field); + if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value)) + yield return field; + } + } + + /// + /// Returns all index fields that are culture specific (suffixed) or invariant + /// + /// + /// + /// + public static IEnumerable GetCultureAndInvariantFields(this IUmbracoIndex index, string culture) + { + var allFields = index.GetFields(); + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (var field in allFields) + { + var match = CultureIsoCodeFieldNameMatchExpression.Match(field); + if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value)) + { + yield return field; //matches this culture field + } + else if (!match.Success) + { + yield return field; //matches no culture field (invariant) + } + + } + } + + public static IBooleanOperation Id(this IQuery query, int id) + { + var fieldQuery = query.Id(id.ToInvariantString()); + return fieldQuery; + } + + /// + /// Query method to search on parent id + /// + /// + /// + /// + public static IBooleanOperation ParentId(this IQuery query, int id) + { + var fieldQuery = query.Field("parentID", id); + return fieldQuery; + } + + /// + /// Query method to search on node name + /// + /// + /// + /// + public static IBooleanOperation NodeName(this IQuery query, string nodeName) + { + var fieldQuery = query.Field(UmbracoExamineFieldNames.NodeNameFieldName, (IExamineValue)new ExamineValue(Examineness.Explicit, nodeName)); + return fieldQuery; + } + + /// + /// Query method to search on node name + /// + /// + /// + /// + public static IBooleanOperation NodeName(this IQuery query, IExamineValue nodeName) + { + var fieldQuery = query.Field(UmbracoExamineFieldNames.NodeNameFieldName, nodeName); + return fieldQuery; + } + + /// + /// Query method to search on node type alias + /// + /// + /// + /// + public static IBooleanOperation NodeTypeAlias(this IQuery query, string nodeTypeAlias) + { + var fieldQuery = query.Field(ExamineFieldNames.ItemTypeFieldName, (IExamineValue)new ExamineValue(Examineness.Explicit, nodeTypeAlias)); + return fieldQuery; + } + + /// + /// Query method to search on node type alias + /// + /// + /// + /// + public static IBooleanOperation NodeTypeAlias(this IQuery query, IExamineValue nodeTypeAlias) + { + var fieldQuery = query.Field(ExamineFieldNames.ItemTypeFieldName, nodeTypeAlias); + return fieldQuery; + } + + } +} diff --git a/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs b/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs index 56eb929f17..9b6d086ae4 100644 --- a/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs +++ b/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs @@ -19,5 +19,7 @@ namespace Umbraco.Examine public const string RawFieldPrefix = ExamineFieldNames.SpecialFieldPrefix + "Raw_"; public const string VariesByCultureFieldName = ExamineFieldNames.SpecialFieldPrefix + "VariesByCulture"; + + public const string NodeNameFieldName = "nodeName"; } } diff --git a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs b/src/Umbraco.Examine2/UmbracoFieldDefinitionCollection.cs similarity index 97% rename from src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs rename to src/Umbraco.Examine2/UmbracoFieldDefinitionCollection.cs index 5633b6a2cc..0ea563e9cc 100644 --- a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs +++ b/src/Umbraco.Examine2/UmbracoFieldDefinitionCollection.cs @@ -76,7 +76,7 @@ namespace Umbraco.Examine if (!fieldName.Contains("_") || !fieldName.Contains("-")) return false; - var match = ExamineExtensions.CultureIsoCodeFieldNameMatchExpression.Match(fieldName); + var match = UmbracoExamineExtensions.CultureIsoCodeFieldNameMatchExpression.Match(fieldName); if (match.Success && match.Groups.Count == 3) { var nonCultureFieldName = match.Groups[1].Value; diff --git a/src/Umbraco.Examine/UmbracoIndexConfig.cs b/src/Umbraco.Examine2/UmbracoIndexConfig.cs similarity index 100% rename from src/Umbraco.Examine/UmbracoIndexConfig.cs rename to src/Umbraco.Examine2/UmbracoIndexConfig.cs diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs index eb126edcff..a5ab3efe82 100644 --- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs +++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs @@ -23,6 +23,7 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Persistence; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Runtime; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.Sync; @@ -89,6 +90,7 @@ namespace Umbraco.Tests.TestHelpers } public static IShortStringHelper ShortStringHelper { get; } = new DefaultShortStringHelper(new DefaultShortStringHelperConfig()); + public static IJsonSerializer JsonSerializer { get; } = new JsonNetSerializer(); public static IVariationContextAccessor VariationContextAccessor { get; } = new TestVariationContextAccessor(); public static IDbProviderFactoryCreator DbProviderFactoryCreator { get; } = new UmbracoDbProviderFactoryCreator(Constants.DbProviderNames.SqlCe); public static IBulkSqlInsertProvider BulkSqlInsertProvider { get; } = new SqlCeBulkSqlInsertProvider(); diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs index d20a87eba9..76ada2169e 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs @@ -47,7 +47,7 @@ namespace Umbraco.Tests.UmbracoExamine public static MediaIndexPopulator GetMediaIndexRebuilder(PropertyEditorCollection propertyEditors, IMediaService mediaService) { - var mediaValueSetBuilder = new MediaValueSetBuilder(propertyEditors, new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(TestHelper.ShortStringHelper) }), GetMockUserService(), GetMockLogger(), TestHelper.ShortStringHelper); + var mediaValueSetBuilder = new MediaValueSetBuilder(propertyEditors, new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(TestHelper.ShortStringHelper) }), GetMockUserService(), GetMockLogger(), TestHelper.ShortStringHelper, TestHelper.JsonSerializer); var mediaIndexDataSource = new MediaIndexPopulator(null, mediaService, mediaValueSetBuilder); return mediaIndexDataSource; } @@ -68,8 +68,8 @@ namespace Umbraco.Tests.UmbracoExamine m.SortOrder == (int)x.Attribute("sortOrder") && m.CreateDate == (DateTime)x.Attribute("createDate") && m.UpdateDate == (DateTime)x.Attribute("updateDate") && - m.Name == (string)x.Attribute("nodeName") && - m.GetCultureName(It.IsAny()) == (string)x.Attribute("nodeName") && + m.Name == (string)x.Attribute(UmbracoExamineFieldNames.NodeNameFieldName) && + m.GetCultureName(It.IsAny()) == (string)x.Attribute(UmbracoExamineFieldNames.NodeNameFieldName) && m.Path == (string)x.Attribute("path") && m.Properties == new PropertyCollection() && m.ContentType == Mock.Of(mt => @@ -108,8 +108,8 @@ namespace Umbraco.Tests.UmbracoExamine m.SortOrder == (int)x.Attribute("sortOrder") && m.CreateDate == (DateTime)x.Attribute("createDate") && m.UpdateDate == (DateTime)x.Attribute("updateDate") && - m.Name == (string)x.Attribute("nodeName") && - m.GetCultureName(It.IsAny()) == (string)x.Attribute("nodeName") && + m.Name == (string)x.Attribute(UmbracoExamineFieldNames.NodeNameFieldName) && + m.GetCultureName(It.IsAny()) == (string)x.Attribute(UmbracoExamineFieldNames.NodeNameFieldName) && m.Path == (string)x.Attribute("path") && m.Properties == new PropertyCollection() && m.ContentType == Mock.Of(mt => diff --git a/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs b/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs index fb6fa4c0c1..dc4f68e823 100644 --- a/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs +++ b/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs @@ -38,8 +38,8 @@ namespace Umbraco.Tests.UmbracoExamine m.SortOrder == (int)x.Attribute("sortOrder") && m.CreateDate == (DateTime)x.Attribute("createDate") && m.UpdateDate == (DateTime)x.Attribute("updateDate") && - m.Name == (string)x.Attribute("nodeName") && - m.GetCultureName(It.IsAny()) == (string)x.Attribute("nodeName") && + m.Name == (string)x.Attribute(UmbracoExamineFieldNames.NodeNameFieldName) && + m.GetCultureName(It.IsAny()) == (string)x.Attribute(UmbracoExamineFieldNames.NodeNameFieldName) && m.Path == (string)x.Attribute("path") && m.Properties == new PropertyCollection() && m.Published == true && diff --git a/src/Umbraco.Web/Editors/ExamineManagementController.cs b/src/Umbraco.Web/Editors/ExamineManagementController.cs index 16bf071445..b66dc0ed6a 100644 --- a/src/Umbraco.Web/Editors/ExamineManagementController.cs +++ b/src/Umbraco.Web/Editors/ExamineManagementController.cs @@ -69,7 +69,7 @@ namespace Umbraco.Web.Editors if (!msg.IsSuccessStatusCode) throw new HttpResponseException(msg); - var results = Examine.ExamineExtensions.TryParseLuceneQuery(query) + var results = global::Umbraco.Examine.ExamineExtensions.TryParseLuceneQuery(query) ? searcher.CreateQuery().NativeQuery(query).Execute(maxResults: pageSize * (pageIndex + 1)) : searcher.Search(query, maxResults: pageSize * (pageIndex + 1)); diff --git a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs index 0697504e2a..308605a197 100644 --- a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs +++ b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs @@ -175,7 +175,7 @@ namespace Umbraco.Web.Models.Mapping ? source.Values[UmbracoExamineFieldNames.IconFieldName] : Constants.Icons.DefaultIcon; - target.Name = source.Values.ContainsKey("nodeName") ? source.Values["nodeName"] : "[no name]"; + target.Name = source.Values.ContainsKey(UmbracoExamineFieldNames.NodeNameFieldName) ? source.Values[UmbracoExamineFieldNames.NodeNameFieldName] : "[no name]"; if (source.Values.TryGetValue(UmbracoExamineFieldNames.UmbracoFileFieldName, out var umbracoFile)) { From 69f4ea5484f08eae50980ebca61a2e4366a5106f Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2020 17:09:45 +1100 Subject: [PATCH 05/16] Renames Umbraco.Examine project to Umbraco.Examine.Lucene for the Lucene implementation part --- .../ExamineExtensions.cs | 0 .../LuceneIndexCreator.cs | 0 .../LuceneIndexDiagnostics.cs | 0 .../NoPrefixSimpleFsLockFactory.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Umbraco.Examine.Lucene.csproj} | 4 ++-- .../UmbracoContentIndex.cs | 0 .../UmbracoExamineExtensions.cs | 0 .../UmbracoExamineIndex.cs | 0 .../UmbracoExamineIndexDiagnostics.cs | 0 .../UmbracoMemberIndex.cs | 0 .../Umbraco.Tests.Benchmarks.csproj | 4 ++-- src/Umbraco.Tests/Umbraco.Tests.csproj | 4 ++-- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 7 ++----- src/Umbraco.Web/Umbraco.Web.csproj | 4 ++-- src/umbraco.sln | 4 ++-- 16 files changed, 12 insertions(+), 15 deletions(-) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/ExamineExtensions.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/LuceneIndexCreator.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/LuceneIndexDiagnostics.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/NoPrefixSimpleFsLockFactory.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/Properties/AssemblyInfo.cs (100%) rename src/{Umbraco.Examine/Umbraco.Examine.csproj => Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj} (96%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/UmbracoContentIndex.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/UmbracoExamineExtensions.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/UmbracoExamineIndex.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/UmbracoExamineIndexDiagnostics.cs (100%) rename src/{Umbraco.Examine => Umbraco.Examine.Lucene}/UmbracoMemberIndex.cs (100%) diff --git a/src/Umbraco.Examine/ExamineExtensions.cs b/src/Umbraco.Examine.Lucene/ExamineExtensions.cs similarity index 100% rename from src/Umbraco.Examine/ExamineExtensions.cs rename to src/Umbraco.Examine.Lucene/ExamineExtensions.cs diff --git a/src/Umbraco.Examine/LuceneIndexCreator.cs b/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs similarity index 100% rename from src/Umbraco.Examine/LuceneIndexCreator.cs rename to src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs diff --git a/src/Umbraco.Examine/LuceneIndexDiagnostics.cs b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs similarity index 100% rename from src/Umbraco.Examine/LuceneIndexDiagnostics.cs rename to src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs diff --git a/src/Umbraco.Examine/NoPrefixSimpleFsLockFactory.cs b/src/Umbraco.Examine.Lucene/NoPrefixSimpleFsLockFactory.cs similarity index 100% rename from src/Umbraco.Examine/NoPrefixSimpleFsLockFactory.cs rename to src/Umbraco.Examine.Lucene/NoPrefixSimpleFsLockFactory.cs diff --git a/src/Umbraco.Examine/Properties/AssemblyInfo.cs b/src/Umbraco.Examine.Lucene/Properties/AssemblyInfo.cs similarity index 100% rename from src/Umbraco.Examine/Properties/AssemblyInfo.cs rename to src/Umbraco.Examine.Lucene/Properties/AssemblyInfo.cs diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj similarity index 96% rename from src/Umbraco.Examine/Umbraco.Examine.csproj rename to src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj index b9ae6a0dcf..1a39d2a6dd 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj @@ -6,7 +6,7 @@ false {07FBC26B-2927-4A22-8D96-D644C667FECC} Library - Umbraco.Examine + Umbraco.Examine.Lucene Umbraco.Examine ..\ @@ -30,7 +30,7 @@ TRACE prompt 4 - bin\Release\Umbraco.Examine.xml + bin\Release\Umbraco.Examine.Lucene.xml false latest diff --git a/src/Umbraco.Examine/UmbracoContentIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs similarity index 100% rename from src/Umbraco.Examine/UmbracoContentIndex.cs rename to src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs diff --git a/src/Umbraco.Examine/UmbracoExamineExtensions.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineExtensions.cs similarity index 100% rename from src/Umbraco.Examine/UmbracoExamineExtensions.cs rename to src/Umbraco.Examine.Lucene/UmbracoExamineExtensions.cs diff --git a/src/Umbraco.Examine/UmbracoExamineIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs similarity index 100% rename from src/Umbraco.Examine/UmbracoExamineIndex.cs rename to src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs diff --git a/src/Umbraco.Examine/UmbracoExamineIndexDiagnostics.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs similarity index 100% rename from src/Umbraco.Examine/UmbracoExamineIndexDiagnostics.cs rename to src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs diff --git a/src/Umbraco.Examine/UmbracoMemberIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs similarity index 100% rename from src/Umbraco.Examine/UmbracoMemberIndex.cs rename to src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs diff --git a/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj b/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj index 1ca47b1b45..2ed47f85c3 100644 --- a/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj +++ b/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj @@ -70,9 +70,9 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions - + {07fbc26b-2927-4a22-8d96-d644c667fecc} - Umbraco.Examine + Umbraco.Examine.Lucene {3ae7bf57-966b-45a5-910a-954d7c554441} diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 2ae54d7aa3..d58ca97fcc 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -584,9 +584,9 @@ {651E1350-91B6-44B7-BD60-7207006D7003} Umbraco.Web - + {07fbc26b-2927-4a22-8d96-d644c667fecc} - Umbraco.Examine + Umbraco.Examine.Lucene diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 56bd423678..2668b38006 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -116,8 +116,8 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions - - Umbraco.Examine + + Umbraco.Examine.Lucene {07FBC26B-2927-4A22-8D96-D644C667FECC} @@ -343,9 +343,6 @@ False True - 9000 - / - http://localhost:9000/ 8700 / http://localhost:8700 diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 8c73da3db8..7881fb2653 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -116,9 +116,9 @@ {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} Umbraco.Examine2 - + {07fbc26b-2927-4a22-8d96-d644c667fecc} - Umbraco.Examine + Umbraco.Examine.Lucene {3ae7bf57-966b-45a5-910a-954d7c554441} diff --git a/src/umbraco.sln b/src/umbraco.sln index 72c713c64f..3c55116909 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -63,7 +63,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web", "Umbraco.Web\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Tests", "Umbraco.Tests\Umbraco.Tests.csproj", "{5D3B8245-ADA6-453F-A008-50ED04BFE770}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine", "Umbraco.Examine\Umbraco.Examine.csproj", "{07FBC26B-2927-4A22-8D96-D644C667FECC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine.Lucene", "Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj", "{07FBC26B-2927-4A22-8D96-D644C667FECC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{E3F9F378-AFE1-40A5-90BD-82833375DBFE}" ProjectSection(SolutionItems) = preProject @@ -113,7 +113,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastrucure.Persi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine2", "Umbraco.Examine2\Umbraco.Examine2.csproj", "{F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine2", "Umbraco.Examine2\Umbraco.Examine2.csproj", "{F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 4183514b5272c7ce6280d9d158a6bc6497145f47 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2020 17:11:43 +1100 Subject: [PATCH 06/16] Renames Examine2 to Examine as the netstandard part --- src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj | 4 ++-- .../BaseValueSetBuilder.cs | 0 .../ContentIndexPopulator.cs | 0 .../ContentValueSetBuilder.cs | 0 .../ContentValueSetValidator.cs | 0 .../IContentValueSetBuilder.cs | 0 .../IContentValueSetValidator.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IIndexCreator.cs | 0 .../IIndexDiagnostics.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IIndexPopulator.cs | 0 .../IPublishedContentValueSetBuilder.cs | 0 .../IUmbracoContentIndex.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IUmbracoIndex.cs | 0 .../IUmbracoIndexConfig.cs | 0 .../IUmbracoMemberIndex.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IValueSetBuilder.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IndexPopulator.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IndexRebuilder.cs | 0 src/{Umbraco.Examine2 => Umbraco.Examine}/IndexTypes.cs | 0 .../MediaIndexPopulator.cs | 0 .../MediaValueSetBuilder.cs | 0 .../MemberIndexPopulator.cs | 0 .../MemberValueSetBuilder.cs | 0 .../MemberValueSetValidator.cs | 0 .../PublishedContentIndexPopulator.cs | 0 .../Umbraco.Examine.csproj} | 2 +- .../UmbracoExamineExtensions.cs | 0 .../UmbracoExamineFieldNames.cs | 0 .../UmbracoFieldDefinitionCollection.cs | 0 .../UmbracoIndexConfig.cs | 0 .../ValueSetValidator.cs | 0 src/Umbraco.Tests/Umbraco.Tests.csproj | 4 ++-- src/Umbraco.Web/Umbraco.Web.csproj | 4 ++-- src/umbraco.sln | 2 +- 34 files changed, 8 insertions(+), 8 deletions(-) rename src/{Umbraco.Examine2 => Umbraco.Examine}/BaseValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/ContentIndexPopulator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/ContentValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/ContentValueSetValidator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IContentValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IContentValueSetValidator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IIndexCreator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IIndexDiagnostics.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IIndexPopulator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IPublishedContentValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IUmbracoContentIndex.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IUmbracoIndex.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IUmbracoIndexConfig.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IUmbracoMemberIndex.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IndexPopulator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IndexRebuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/IndexTypes.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/MediaIndexPopulator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/MediaValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/MemberIndexPopulator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/MemberValueSetBuilder.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/MemberValueSetValidator.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/PublishedContentIndexPopulator.cs (100%) rename src/{Umbraco.Examine2/Umbraco.Examine2.csproj => Umbraco.Examine/Umbraco.Examine.csproj} (91%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/UmbracoExamineExtensions.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/UmbracoExamineFieldNames.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/UmbracoFieldDefinitionCollection.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/UmbracoIndexConfig.cs (100%) rename src/{Umbraco.Examine2 => Umbraco.Examine}/ValueSetValidator.cs (100%) diff --git a/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj index 1a39d2a6dd..8df6aafa2d 100644 --- a/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj +++ b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj @@ -85,9 +85,9 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions - + {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} - Umbraco.Examine2 + Umbraco.Examine {3ae7bf57-966b-45a5-910a-954d7c554441} diff --git a/src/Umbraco.Examine2/BaseValueSetBuilder.cs b/src/Umbraco.Examine/BaseValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/BaseValueSetBuilder.cs rename to src/Umbraco.Examine/BaseValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/ContentIndexPopulator.cs b/src/Umbraco.Examine/ContentIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine2/ContentIndexPopulator.cs rename to src/Umbraco.Examine/ContentIndexPopulator.cs diff --git a/src/Umbraco.Examine2/ContentValueSetBuilder.cs b/src/Umbraco.Examine/ContentValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/ContentValueSetBuilder.cs rename to src/Umbraco.Examine/ContentValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/ContentValueSetValidator.cs b/src/Umbraco.Examine/ContentValueSetValidator.cs similarity index 100% rename from src/Umbraco.Examine2/ContentValueSetValidator.cs rename to src/Umbraco.Examine/ContentValueSetValidator.cs diff --git a/src/Umbraco.Examine2/IContentValueSetBuilder.cs b/src/Umbraco.Examine/IContentValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/IContentValueSetBuilder.cs rename to src/Umbraco.Examine/IContentValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/IContentValueSetValidator.cs b/src/Umbraco.Examine/IContentValueSetValidator.cs similarity index 100% rename from src/Umbraco.Examine2/IContentValueSetValidator.cs rename to src/Umbraco.Examine/IContentValueSetValidator.cs diff --git a/src/Umbraco.Examine2/IIndexCreator.cs b/src/Umbraco.Examine/IIndexCreator.cs similarity index 100% rename from src/Umbraco.Examine2/IIndexCreator.cs rename to src/Umbraco.Examine/IIndexCreator.cs diff --git a/src/Umbraco.Examine2/IIndexDiagnostics.cs b/src/Umbraco.Examine/IIndexDiagnostics.cs similarity index 100% rename from src/Umbraco.Examine2/IIndexDiagnostics.cs rename to src/Umbraco.Examine/IIndexDiagnostics.cs diff --git a/src/Umbraco.Examine2/IIndexPopulator.cs b/src/Umbraco.Examine/IIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine2/IIndexPopulator.cs rename to src/Umbraco.Examine/IIndexPopulator.cs diff --git a/src/Umbraco.Examine2/IPublishedContentValueSetBuilder.cs b/src/Umbraco.Examine/IPublishedContentValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/IPublishedContentValueSetBuilder.cs rename to src/Umbraco.Examine/IPublishedContentValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/IUmbracoContentIndex.cs b/src/Umbraco.Examine/IUmbracoContentIndex.cs similarity index 100% rename from src/Umbraco.Examine2/IUmbracoContentIndex.cs rename to src/Umbraco.Examine/IUmbracoContentIndex.cs diff --git a/src/Umbraco.Examine2/IUmbracoIndex.cs b/src/Umbraco.Examine/IUmbracoIndex.cs similarity index 100% rename from src/Umbraco.Examine2/IUmbracoIndex.cs rename to src/Umbraco.Examine/IUmbracoIndex.cs diff --git a/src/Umbraco.Examine2/IUmbracoIndexConfig.cs b/src/Umbraco.Examine/IUmbracoIndexConfig.cs similarity index 100% rename from src/Umbraco.Examine2/IUmbracoIndexConfig.cs rename to src/Umbraco.Examine/IUmbracoIndexConfig.cs diff --git a/src/Umbraco.Examine2/IUmbracoMemberIndex.cs b/src/Umbraco.Examine/IUmbracoMemberIndex.cs similarity index 100% rename from src/Umbraco.Examine2/IUmbracoMemberIndex.cs rename to src/Umbraco.Examine/IUmbracoMemberIndex.cs diff --git a/src/Umbraco.Examine2/IValueSetBuilder.cs b/src/Umbraco.Examine/IValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/IValueSetBuilder.cs rename to src/Umbraco.Examine/IValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/IndexPopulator.cs b/src/Umbraco.Examine/IndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine2/IndexPopulator.cs rename to src/Umbraco.Examine/IndexPopulator.cs diff --git a/src/Umbraco.Examine2/IndexRebuilder.cs b/src/Umbraco.Examine/IndexRebuilder.cs similarity index 100% rename from src/Umbraco.Examine2/IndexRebuilder.cs rename to src/Umbraco.Examine/IndexRebuilder.cs diff --git a/src/Umbraco.Examine2/IndexTypes.cs b/src/Umbraco.Examine/IndexTypes.cs similarity index 100% rename from src/Umbraco.Examine2/IndexTypes.cs rename to src/Umbraco.Examine/IndexTypes.cs diff --git a/src/Umbraco.Examine2/MediaIndexPopulator.cs b/src/Umbraco.Examine/MediaIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine2/MediaIndexPopulator.cs rename to src/Umbraco.Examine/MediaIndexPopulator.cs diff --git a/src/Umbraco.Examine2/MediaValueSetBuilder.cs b/src/Umbraco.Examine/MediaValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/MediaValueSetBuilder.cs rename to src/Umbraco.Examine/MediaValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/MemberIndexPopulator.cs b/src/Umbraco.Examine/MemberIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine2/MemberIndexPopulator.cs rename to src/Umbraco.Examine/MemberIndexPopulator.cs diff --git a/src/Umbraco.Examine2/MemberValueSetBuilder.cs b/src/Umbraco.Examine/MemberValueSetBuilder.cs similarity index 100% rename from src/Umbraco.Examine2/MemberValueSetBuilder.cs rename to src/Umbraco.Examine/MemberValueSetBuilder.cs diff --git a/src/Umbraco.Examine2/MemberValueSetValidator.cs b/src/Umbraco.Examine/MemberValueSetValidator.cs similarity index 100% rename from src/Umbraco.Examine2/MemberValueSetValidator.cs rename to src/Umbraco.Examine/MemberValueSetValidator.cs diff --git a/src/Umbraco.Examine2/PublishedContentIndexPopulator.cs b/src/Umbraco.Examine/PublishedContentIndexPopulator.cs similarity index 100% rename from src/Umbraco.Examine2/PublishedContentIndexPopulator.cs rename to src/Umbraco.Examine/PublishedContentIndexPopulator.cs diff --git a/src/Umbraco.Examine2/Umbraco.Examine2.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj similarity index 91% rename from src/Umbraco.Examine2/Umbraco.Examine2.csproj rename to src/Umbraco.Examine/Umbraco.Examine.csproj index e994fcfa47..93edee43f5 100644 --- a/src/Umbraco.Examine2/Umbraco.Examine2.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -2,7 +2,7 @@ netstandard2.0 - Umbraco.Examine2 + Umbraco.Examine Umbraco.Examine diff --git a/src/Umbraco.Examine2/UmbracoExamineExtensions.cs b/src/Umbraco.Examine/UmbracoExamineExtensions.cs similarity index 100% rename from src/Umbraco.Examine2/UmbracoExamineExtensions.cs rename to src/Umbraco.Examine/UmbracoExamineExtensions.cs diff --git a/src/Umbraco.Examine2/UmbracoExamineFieldNames.cs b/src/Umbraco.Examine/UmbracoExamineFieldNames.cs similarity index 100% rename from src/Umbraco.Examine2/UmbracoExamineFieldNames.cs rename to src/Umbraco.Examine/UmbracoExamineFieldNames.cs diff --git a/src/Umbraco.Examine2/UmbracoFieldDefinitionCollection.cs b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs similarity index 100% rename from src/Umbraco.Examine2/UmbracoFieldDefinitionCollection.cs rename to src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs diff --git a/src/Umbraco.Examine2/UmbracoIndexConfig.cs b/src/Umbraco.Examine/UmbracoIndexConfig.cs similarity index 100% rename from src/Umbraco.Examine2/UmbracoIndexConfig.cs rename to src/Umbraco.Examine/UmbracoIndexConfig.cs diff --git a/src/Umbraco.Examine2/ValueSetValidator.cs b/src/Umbraco.Examine/ValueSetValidator.cs similarity index 100% rename from src/Umbraco.Examine2/ValueSetValidator.cs rename to src/Umbraco.Examine/ValueSetValidator.cs diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index d58ca97fcc..887ee3c01f 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -564,9 +564,9 @@ {fbe7c065-dac0-4025-a78b-63b24d3ab00b} Umbraco.Configuration - + {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} - Umbraco.Examine2 + Umbraco.Examine {3ae7bf57-966b-45a5-910a-954d7c554441} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 7881fb2653..9d226cda3d 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -112,9 +112,9 @@ {fbe7c065-dac0-4025-a78b-63b24d3ab00b} Umbraco.Configuration - + {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} - Umbraco.Examine2 + Umbraco.Examine {07fbc26b-2927-4a22-8d96-d644c667fecc} diff --git a/src/umbraco.sln b/src/umbraco.sln index 3c55116909..338bc3f3dd 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -113,7 +113,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastrucure.Persi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine2", "Umbraco.Examine2\Umbraco.Examine2.csproj", "{F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine", "Umbraco.Examine\Umbraco.Examine.csproj", "{F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 5b5aa4c499ff18d1008737011308efe09fff09ab Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Jan 2020 12:24:57 +1100 Subject: [PATCH 07/16] All Lucene based logic is part of Umbraco.Examine.Lucene, no other part of Umbraco now knows about Lucene at all. --- .../Search/IUmbracoTreeSearcherFields.cs | 2 +- .../BackOfficeExamineSearcher.cs | 346 ++++++++++++++++++ .../ExamineExtensions.cs | 7 +- .../ExamineLuceneComponent.cs | 50 +++ .../ExamineLuceneComposer.cs | 21 ++ .../ExamineLuceneFinalComponent.cs | 33 ++ .../ExamineLuceneFinalComposer.cs | 13 + .../LuceneIndexDiagnosticsFactory.cs | 35 ++ .../Umbraco.Examine.Lucene.csproj | 7 + .../UmbracoIndexesCreator.cs | 4 +- .../UmbracoMemberIndex.cs | 4 +- .../GenericIndexDiagnostics.cs | 3 +- .../IBackOfficeExamineSearcher.cs | 17 + src/Umbraco.Examine/IIndexDiagnostics.cs | 1 + .../IIndexDiagnosticsFactory.cs | 13 + .../IUmbracoIndexesCreator.cs | 6 +- .../IndexDiagnosticsFactory.cs | 17 + src/Umbraco.Examine/IndexRebuilder.cs | 10 +- .../IndexRebuildingEventArgs.cs | 19 + .../Editors/ExamineManagementController.cs | 20 +- src/Umbraco.Web/ExamineExtensions.cs | 2 - .../Models/Mapping/EntityMapDefinition.cs | 2 - src/Umbraco.Web/Runtime/WebInitialComposer.cs | 1 + .../Search/BackgroundIndexRebuilder.cs | 1 - src/Umbraco.Web/Search/ExamineComponent.cs | 12 - src/Umbraco.Web/Search/ExamineComposer.cs | 2 +- .../Search/ExamineFinalComponent.cs | 8 +- src/Umbraco.Web/Search/UmbracoTreeSearcher.cs | 310 +--------------- src/Umbraco.Web/Umbraco.Web.csproj | 11 - 29 files changed, 602 insertions(+), 375 deletions(-) rename src/{Umbraco.Web => Umbraco.Abstractions}/Search/IUmbracoTreeSearcherFields.cs (99%) create mode 100644 src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs create mode 100644 src/Umbraco.Examine.Lucene/ExamineLuceneComponent.cs create mode 100644 src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs create mode 100644 src/Umbraco.Examine.Lucene/ExamineLuceneFinalComponent.cs create mode 100644 src/Umbraco.Examine.Lucene/ExamineLuceneFinalComposer.cs create mode 100644 src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs rename src/{Umbraco.Web/Search => Umbraco.Examine.Lucene}/UmbracoIndexesCreator.cs (97%) rename src/{Umbraco.Web/Search => Umbraco.Examine}/GenericIndexDiagnostics.cs (97%) create mode 100644 src/Umbraco.Examine/IBackOfficeExamineSearcher.cs create mode 100644 src/Umbraco.Examine/IIndexDiagnosticsFactory.cs rename src/{Umbraco.Web/Search => Umbraco.Examine}/IUmbracoIndexesCreator.cs (63%) create mode 100644 src/Umbraco.Examine/IndexDiagnosticsFactory.cs create mode 100644 src/Umbraco.Examine/IndexRebuildingEventArgs.cs diff --git a/src/Umbraco.Web/Search/IUmbracoTreeSearcherFields.cs b/src/Umbraco.Abstractions/Search/IUmbracoTreeSearcherFields.cs similarity index 99% rename from src/Umbraco.Web/Search/IUmbracoTreeSearcherFields.cs rename to src/Umbraco.Abstractions/Search/IUmbracoTreeSearcherFields.cs index c5a6c53d19..fdbf5bf60d 100644 --- a/src/Umbraco.Web/Search/IUmbracoTreeSearcherFields.cs +++ b/src/Umbraco.Abstractions/Search/IUmbracoTreeSearcherFields.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; namespace Umbraco.Web.Search -{ +{ /// /// Used to propagate hardcoded internal Field lists /// diff --git a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs new file mode 100644 index 0000000000..71d192146b --- /dev/null +++ b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs @@ -0,0 +1,346 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Examine; +using Umbraco.Core; +using Umbraco.Core.Models; +using Umbraco.Core.Models.Identity; +using Umbraco.Core.Persistence; +using Umbraco.Core.Services; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Search; + +namespace Umbraco.Examine +{ + public class BackOfficeExamineSearcher : IBackOfficeExamineSearcher + { + private readonly IExamineManager _examineManager; + private readonly ILocalizationService _languageService; + private readonly ICurrentUserAccessor _currentUserAccessor; + private readonly IEntityService _entityService; + private readonly IUmbracoTreeSearcherFields _treeSearcherFields; + + public BackOfficeExamineSearcher(IExamineManager examineManager, + ILocalizationService languageService, + ICurrentUserAccessor currentUserAccessor, + IEntityService entityService, + IUmbracoTreeSearcherFields treeSearcherFields) + { + _examineManager = examineManager; + _languageService = languageService; + _currentUserAccessor = currentUserAccessor; + _entityService = entityService; + _treeSearcherFields = treeSearcherFields; + } + + public IEnumerable Search(string query, UmbracoEntityTypes entityType, int pageSize, long pageIndex, out long totalFound, string searchFrom = null, bool ignoreUserStartNodes = false) + { + var sb = new StringBuilder(); + + string type; + var indexName = Constants.UmbracoIndexes.InternalIndexName; + var fields = _treeSearcherFields.GetBackOfficeFields().ToList(); + + // TODO: WE should try to allow passing in a lucene raw query, however we will still need to do some manual string + // manipulation for things like start paths, member types, etc... + //if (Examine.ExamineExtensions.TryParseLuceneQuery(query)) + //{ + + //} + + //special GUID check since if a user searches on one specifically we need to escape it + if (Guid.TryParse(query, out var g)) + { + query = "\"" + g.ToString() + "\""; + } + + var currentUser = _currentUserAccessor.TryGetCurrentUser(); + + switch (entityType) + { + case UmbracoEntityTypes.Member: + indexName = Constants.UmbracoIndexes.MembersIndexName; + type = "member"; + fields.AddRange(_treeSearcherFields.GetBackOfficeMembersFields()); + if (searchFrom != null && searchFrom != Constants.Conventions.MemberTypes.AllMembersListId && searchFrom.Trim() != "-1") + { + sb.Append("+__NodeTypeAlias:"); + sb.Append(searchFrom); + sb.Append(" "); + } + break; + case UmbracoEntityTypes.Media: + type = "media"; + fields.AddRange(_treeSearcherFields.GetBackOfficeMediaFields()); + var allMediaStartNodes = currentUser != null + ? currentUser.CalculateMediaStartNodeIds(_entityService) + : Array.Empty(); + AppendPath(sb, UmbracoObjectTypes.Media, allMediaStartNodes, searchFrom, ignoreUserStartNodes, _entityService); + break; + case UmbracoEntityTypes.Document: + type = "content"; + fields.AddRange(_treeSearcherFields.GetBackOfficeDocumentFields()); + var allContentStartNodes = currentUser != null + ? currentUser.CalculateContentStartNodeIds(_entityService) + : Array.Empty(); + AppendPath(sb, UmbracoObjectTypes.Document, allContentStartNodes, searchFrom, ignoreUserStartNodes, _entityService); + break; + default: + throw new NotSupportedException("The " + typeof(BackOfficeExamineSearcher) + " currently does not support searching against object type " + entityType); + } + + if (!_examineManager.TryGetIndex(indexName, out var index)) + throw new InvalidOperationException("No index found by name " + indexName); + + var internalSearcher = index.GetSearcher(); + + if (!BuildQuery(sb, query, searchFrom, fields, type)) + { + totalFound = 0; + return Enumerable.Empty(); + } + + var result = internalSearcher.CreateQuery().NativeQuery(sb.ToString()) + //only return the number of items specified to read up to the amount of records to fill from 0 -> the number of items on the page requested + .Execute(Convert.ToInt32(pageSize * (pageIndex + 1))); + + totalFound = result.TotalItemCount; + + var pagedResult = result.Skip(Convert.ToInt32(pageIndex)); + + return pagedResult; + } + + private bool BuildQuery(StringBuilder sb, string query, string searchFrom, List fields, string type) + { + //build a lucene query: + // the nodeName will be boosted 10x without wildcards + // then nodeName will be matched normally with wildcards + // the rest will be normal without wildcards + + var allLangs = _languageService.GetAllLanguages().Select(x => x.IsoCode.ToLowerInvariant()).ToList(); + + //check if text is surrounded by single or double quotes, if so, then exact match + var surroundedByQuotes = Regex.IsMatch(query, "^\".*?\"$") + || Regex.IsMatch(query, "^\'.*?\'$"); + + if (surroundedByQuotes) + { + //strip quotes, escape string, the replace again + query = query.Trim('\"', '\''); + + query = Lucene.Net.QueryParsers.QueryParser.Escape(query); + + //nothing to search + if (searchFrom.IsNullOrWhiteSpace() && query.IsNullOrWhiteSpace()) + { + return false; + } + + //update the query with the query term + if (query.IsNullOrWhiteSpace() == false) + { + //add back the surrounding quotes + query = string.Format("{0}{1}{0}", "\"", query); + + sb.Append("+("); + + AppendNodeNamePhraseWithBoost(sb, query, allLangs); + + foreach (var f in fields) + { + //additional fields normally + sb.Append(f); + sb.Append(": ("); + sb.Append(query); + sb.Append(") "); + } + + sb.Append(") "); + } + } + else + { + var trimmed = query.Trim(new[] { '\"', '\'' }); + + //nothing to search + if (searchFrom.IsNullOrWhiteSpace() && trimmed.IsNullOrWhiteSpace()) + { + return false; + } + + //update the query with the query term + if (trimmed.IsNullOrWhiteSpace() == false) + { + query = Lucene.Net.QueryParsers.QueryParser.Escape(query); + + var querywords = query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + + sb.Append("+("); + + AppendNodeNameExactWithBoost(sb, query, allLangs); + + AppendNodeNameWithWildcards(sb, querywords, allLangs); + + foreach (var f in fields) + { + var queryWordsReplaced = new string[querywords.Length]; + + // when searching file names containing hyphens we need to replace the hyphens with spaces + if (f.Equals(UmbracoExamineFieldNames.UmbracoFileFieldName)) + { + for (var index = 0; index < querywords.Length; index++) + { + queryWordsReplaced[index] = querywords[index].Replace("\\-", " ").Replace("_", " ").Trim(" "); + } + } + else + { + queryWordsReplaced = querywords; + } + + //additional fields normally + sb.Append(f); + sb.Append(":"); + sb.Append("("); + foreach (var w in queryWordsReplaced) + { + sb.Append(w.ToLower()); + sb.Append("* "); + } + sb.Append(")"); + sb.Append(" "); + } + + sb.Append(") "); + } + } + + //must match index type + sb.Append("+__IndexType:"); + sb.Append(type); + + return true; + } + + private void AppendNodeNamePhraseWithBoost(StringBuilder sb, string query, IEnumerable allLangs) + { + //node name exactly boost x 10 + sb.Append("nodeName: ("); + sb.Append(query.ToLower()); + sb.Append(")^10.0 "); + + //also search on all variant node names + foreach (var lang in allLangs) + { + //node name exactly boost x 10 + sb.Append($"nodeName_{lang}: ("); + sb.Append(query.ToLower()); + sb.Append(")^10.0 "); + } + } + + private void AppendNodeNameExactWithBoost(StringBuilder sb, string query, IEnumerable allLangs) + { + //node name exactly boost x 10 + sb.Append("nodeName:"); + sb.Append("\""); + sb.Append(query.ToLower()); + sb.Append("\""); + sb.Append("^10.0 "); + //also search on all variant node names + foreach (var lang in allLangs) + { + //node name exactly boost x 10 + sb.Append($"nodeName_{lang}:"); + sb.Append("\""); + sb.Append(query.ToLower()); + sb.Append("\""); + sb.Append("^10.0 "); + } + } + + private void AppendNodeNameWithWildcards(StringBuilder sb, string[] querywords, IEnumerable allLangs) + { + //node name normally with wildcards + sb.Append("nodeName:"); + sb.Append("("); + foreach (var w in querywords) + { + sb.Append(w.ToLower()); + sb.Append("* "); + } + sb.Append(") "); + //also search on all variant node names + foreach (var lang in allLangs) + { + //node name normally with wildcards + sb.Append($"nodeName_{lang}:"); + sb.Append("("); + foreach (var w in querywords) + { + sb.Append(w.ToLower()); + sb.Append("* "); + } + sb.Append(") "); + } + } + + private void AppendPath(StringBuilder sb, UmbracoObjectTypes objectType, int[] startNodeIds, string searchFrom, bool ignoreUserStartNodes, IEntityService entityService) + { + if (sb == null) throw new ArgumentNullException(nameof(sb)); + if (entityService == null) throw new ArgumentNullException(nameof(entityService)); + + UdiParser.TryParse(searchFrom, true, out var udi); + searchFrom = udi == null ? searchFrom : entityService.GetId(udi).Result.ToString(); + + var entityPath = int.TryParse(searchFrom, out var searchFromId) && searchFromId > 0 + ? entityService.GetAllPaths(objectType, searchFromId).FirstOrDefault() + : null; + if (entityPath != null) + { + // find... only what's underneath + sb.Append("+__Path:"); + AppendPath(sb, entityPath.Path, false); + sb.Append(" "); + } + else if (startNodeIds.Length == 0) + { + // make sure we don't find anything + sb.Append("+__Path:none "); + } + else if (startNodeIds.Contains(-1) == false && ignoreUserStartNodes == false) // -1 = no restriction + { + var entityPaths = entityService.GetAllPaths(objectType, startNodeIds); + + // for each start node, find the start node, and what's underneath + // +__Path:(-1*,1234 -1*,1234,* -1*,5678 -1*,5678,* ...) + sb.Append("+__Path:("); + var first = true; + foreach (var ep in entityPaths) + { + if (first) + first = false; + else + sb.Append(" "); + AppendPath(sb, ep.Path, true); + } + sb.Append(") "); + } + } + + private void AppendPath(StringBuilder sb, string path, bool includeThisNode) + { + path = path.Replace("-", "\\-").Replace(",", "\\,"); + if (includeThisNode) + { + sb.Append(path); + sb.Append(" "); + } + sb.Append(path); + sb.Append("\\,*"); + } + } +} diff --git a/src/Umbraco.Examine.Lucene/ExamineExtensions.cs b/src/Umbraco.Examine.Lucene/ExamineExtensions.cs index 2b763305c2..d697bf6f0d 100644 --- a/src/Umbraco.Examine.Lucene/ExamineExtensions.cs +++ b/src/Umbraco.Examine.Lucene/ExamineExtensions.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text.RegularExpressions; using Examine; using Examine.LuceneEngine.Providers; using Lucene.Net.Analysis; @@ -15,13 +13,12 @@ using System.Threading; namespace Umbraco.Examine { + /// /// Extension methods for the LuceneIndex /// public static class ExamineExtensions { - - private static bool _isConfigured = false; private static object _configuredInit = null; private static object _isConfiguredLocker = new object(); @@ -74,7 +71,7 @@ namespace Umbraco.Examine /// /// This is not thread safe, use with care /// - internal static void ConfigureLuceneIndexes(this IExamineManager examineManager, ILogger logger, bool disableExamineIndexing) + private static void ConfigureLuceneIndexes(this IExamineManager examineManager, ILogger logger, bool disableExamineIndexing) { foreach (var luceneIndexer in examineManager.Indexes.OfType()) { diff --git a/src/Umbraco.Examine.Lucene/ExamineLuceneComponent.cs b/src/Umbraco.Examine.Lucene/ExamineLuceneComponent.cs new file mode 100644 index 0000000000..0d701d388d --- /dev/null +++ b/src/Umbraco.Examine.Lucene/ExamineLuceneComponent.cs @@ -0,0 +1,50 @@ +using Examine; +using Examine.LuceneEngine.Directories; +using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Core.Logging; + +namespace Umbraco.Examine +{ + + public sealed class ExamineLuceneComponent : IComponent + { + private readonly IndexRebuilder _indexRebuilder; + private readonly IExamineManager _examineManager; + private readonly IMainDom _mainDom; + private readonly ILogger _logger; + + public ExamineLuceneComponent(IndexRebuilder indexRebuilder, IExamineManager examineManager, IMainDom mainDom, ILogger logger) + { + _indexRebuilder = indexRebuilder; + _examineManager = examineManager; + _mainDom = mainDom; + _logger = logger; + } + + public void Initialize() + { + //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the AppDomain + //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock + //which simply checks the existence of the lock file + DirectoryFactory.DefaultLockFactory = d => + { + var simpleFsLockFactory = new NoPrefixSimpleFsLockFactory(d); + return simpleFsLockFactory; + }; + + _indexRebuilder.RebuildingIndexes += IndexRebuilder_RebuildingIndexes; + } + + /// + /// Handles event to ensure that all lucene based indexes are properly configured before rebuilding + /// + /// + /// + private void IndexRebuilder_RebuildingIndexes(object sender, IndexRebuildingEventArgs e) => _examineManager.ConfigureIndexes(_mainDom, _logger); + + public void Terminate() + { + } + } +} diff --git a/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs b/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs new file mode 100644 index 0000000000..0334531691 --- /dev/null +++ b/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs @@ -0,0 +1,21 @@ +using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Web.Search; + +namespace Umbraco.Examine +{ + // We want to run after core composers since we are replacing some items + [ComposeAfter(typeof(ICoreComposer))] + [RuntimeLevel(MinLevel = RuntimeLevel.Run)] + public sealed class ExamineLuceneComposer : ComponentComposer + { + public override void Compose(Composition composition) + { + base.Compose(composition); + + composition.RegisterUnique(); + composition.RegisterUnique(); + composition.RegisterUnique(); + } + } +} diff --git a/src/Umbraco.Examine.Lucene/ExamineLuceneFinalComponent.cs b/src/Umbraco.Examine.Lucene/ExamineLuceneFinalComponent.cs new file mode 100644 index 0000000000..e1e80ead2f --- /dev/null +++ b/src/Umbraco.Examine.Lucene/ExamineLuceneFinalComponent.cs @@ -0,0 +1,33 @@ +using Examine; +using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Core.Logging; + +namespace Umbraco.Examine +{ + public class ExamineLuceneFinalComponent : IComponent + { + private readonly IProfilingLogger _logger; + private readonly IExamineManager _examineManager; + private readonly IMainDom _mainDom; + + public ExamineLuceneFinalComponent(IProfilingLogger logger, IExamineManager examineManager, IMainDom mainDom) + { + _logger = logger; + _examineManager = examineManager; + _mainDom = mainDom; + } + + public void Initialize() + { + if (!_mainDom.IsMainDom) return; + + // Ensures all lucene based indexes are unlocked and ready to go + _examineManager.ConfigureIndexes(_mainDom, _logger); + } + + public void Terminate() + { + } + } +} diff --git a/src/Umbraco.Examine.Lucene/ExamineLuceneFinalComposer.cs b/src/Umbraco.Examine.Lucene/ExamineLuceneFinalComposer.cs new file mode 100644 index 0000000000..1a73426568 --- /dev/null +++ b/src/Umbraco.Examine.Lucene/ExamineLuceneFinalComposer.cs @@ -0,0 +1,13 @@ +using Umbraco.Core; +using Umbraco.Core.Composing; + +namespace Umbraco.Examine +{ + // examine's Lucene final composer composes after all user composers + // and *also* after ICoreComposer (in case IUserComposer is disabled) + [ComposeAfter(typeof(IUserComposer))] + [ComposeAfter(typeof(ICoreComposer))] + [RuntimeLevel(MinLevel = RuntimeLevel.Run)] + public class ExamineLuceneFinalComposer : ComponentComposer + { } +} diff --git a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs new file mode 100644 index 0000000000..cc1fc115ca --- /dev/null +++ b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs @@ -0,0 +1,35 @@ +using Examine; +using Examine.LuceneEngine.Providers; +using Umbraco.Core.Logging; +using Umbraco.Core.IO; + +namespace Umbraco.Examine +{ + /// + /// Implementation of which returns + /// for lucene based indexes that don't have an implementation else fallsback to the default implementation. + /// + public class LuceneIndexDiagnosticsFactory : IndexDiagnosticsFactory + { + private readonly ILogger _logger; + private readonly IIOHelper _ioHelper; + + public LuceneIndexDiagnosticsFactory(ILogger logger, IIOHelper ioHelper) + { + _logger = logger; + _ioHelper = ioHelper; + } + + public override IIndexDiagnostics Create(IIndex index) + { + if (!(index is IIndexDiagnostics indexDiag)) + { + if (index is LuceneIndex luceneIndex) + indexDiag = new LuceneIndexDiagnostics(luceneIndex, _logger, _ioHelper); + else + indexDiag = base.Create(index); + } + return indexDiag; + } + } +} diff --git a/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj index 8df6aafa2d..255df2d2d6 100644 --- a/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj +++ b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj @@ -66,8 +66,14 @@ + + + + + + @@ -75,6 +81,7 @@ + Properties\SolutionInfo.cs diff --git a/src/Umbraco.Web/Search/UmbracoIndexesCreator.cs b/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs similarity index 97% rename from src/Umbraco.Web/Search/UmbracoIndexesCreator.cs rename to src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs index 71b5bee108..8e50c6ebc4 100644 --- a/src/Umbraco.Web/Search/UmbracoIndexesCreator.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Examine; @@ -9,7 +8,6 @@ using Examine; using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.IO; -using Umbraco.Web.PublishedCache.NuCache; namespace Umbraco.Web.Search { diff --git a/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs index 494c661062..0e9128d31a 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using Examine; -using Examine.LuceneEngine; +using Examine; using Lucene.Net.Analysis; using Umbraco.Core; using Umbraco.Core.IO; diff --git a/src/Umbraco.Web/Search/GenericIndexDiagnostics.cs b/src/Umbraco.Examine/GenericIndexDiagnostics.cs similarity index 97% rename from src/Umbraco.Web/Search/GenericIndexDiagnostics.cs rename to src/Umbraco.Examine/GenericIndexDiagnostics.cs index cb25e1242a..c384392710 100644 --- a/src/Umbraco.Web/Search/GenericIndexDiagnostics.cs +++ b/src/Umbraco.Examine/GenericIndexDiagnostics.cs @@ -4,9 +4,8 @@ using System.Linq; using Examine; using Umbraco.Core; using Umbraco.Core.Composing; -using Umbraco.Examine; -namespace Umbraco.Web.Search +namespace Umbraco.Examine { /// diff --git a/src/Umbraco.Examine/IBackOfficeExamineSearcher.cs b/src/Umbraco.Examine/IBackOfficeExamineSearcher.cs new file mode 100644 index 0000000000..719d5a33f2 --- /dev/null +++ b/src/Umbraco.Examine/IBackOfficeExamineSearcher.cs @@ -0,0 +1,17 @@ +using Examine; +using System.Collections.Generic; +using Umbraco.Web.Models.ContentEditing; + +namespace Umbraco.Examine +{ + /// + /// Used to search the back office for Examine indexed entities (Documents, Media and Members) + /// + public interface IBackOfficeExamineSearcher + { + IEnumerable Search(string query, + UmbracoEntityTypes entityType, + int pageSize, + long pageIndex, out long totalFound, string searchFrom = null, bool ignoreUserStartNodes = false); + } +} diff --git a/src/Umbraco.Examine/IIndexDiagnostics.cs b/src/Umbraco.Examine/IIndexDiagnostics.cs index 29d530c2d0..b51f6f256f 100644 --- a/src/Umbraco.Examine/IIndexDiagnostics.cs +++ b/src/Umbraco.Examine/IIndexDiagnostics.cs @@ -4,6 +4,7 @@ using Umbraco.Core; namespace Umbraco.Examine { + /// /// Exposes diagnostic information about an index /// diff --git a/src/Umbraco.Examine/IIndexDiagnosticsFactory.cs b/src/Umbraco.Examine/IIndexDiagnosticsFactory.cs new file mode 100644 index 0000000000..f7922e64cb --- /dev/null +++ b/src/Umbraco.Examine/IIndexDiagnosticsFactory.cs @@ -0,0 +1,13 @@ +using Examine; + +namespace Umbraco.Examine +{ + + /// + /// Creates for an index if it doesn't implement + /// + public interface IIndexDiagnosticsFactory + { + IIndexDiagnostics Create(IIndex index); + } +} diff --git a/src/Umbraco.Web/Search/IUmbracoIndexesCreator.cs b/src/Umbraco.Examine/IUmbracoIndexesCreator.cs similarity index 63% rename from src/Umbraco.Web/Search/IUmbracoIndexesCreator.cs rename to src/Umbraco.Examine/IUmbracoIndexesCreator.cs index d654e4effd..d64046a940 100644 --- a/src/Umbraco.Web/Search/IUmbracoIndexesCreator.cs +++ b/src/Umbraco.Examine/IUmbracoIndexesCreator.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using Examine; -using Umbraco.Examine; - -namespace Umbraco.Web.Search +namespace Umbraco.Examine { /// /// diff --git a/src/Umbraco.Examine/IndexDiagnosticsFactory.cs b/src/Umbraco.Examine/IndexDiagnosticsFactory.cs new file mode 100644 index 0000000000..9daa1705a9 --- /dev/null +++ b/src/Umbraco.Examine/IndexDiagnosticsFactory.cs @@ -0,0 +1,17 @@ +using Examine; + +namespace Umbraco.Examine +{ + /// + /// Default implementation of which returns for indexes that don't have an implementation + /// + public class IndexDiagnosticsFactory : IIndexDiagnosticsFactory + { + public virtual IIndexDiagnostics Create(IIndex index) + { + if (!(index is IIndexDiagnostics indexDiag)) + indexDiag = new GenericIndexDiagnostics(index); + return indexDiag; + } + } +} diff --git a/src/Umbraco.Examine/IndexRebuilder.cs b/src/Umbraco.Examine/IndexRebuilder.cs index 786aecac71..d87241e6f6 100644 --- a/src/Umbraco.Examine/IndexRebuilder.cs +++ b/src/Umbraco.Examine/IndexRebuilder.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Examine; namespace Umbraco.Examine -{ +{ /// /// Utility to rebuild all indexes ensuring minimal data queries @@ -45,6 +45,8 @@ namespace Umbraco.Examine if (indexes.Length == 0) return; + OnRebuildingIndexes(new IndexRebuildingEventArgs(indexes)); + foreach (var index in indexes) { index.CreateIndex(); // clear the index @@ -54,5 +56,11 @@ namespace Umbraco.Examine Parallel.ForEach(_populators, populator => populator.Populate(indexes)); } + /// + /// Event raised when indexes are being rebuilt + /// + public event EventHandler RebuildingIndexes; + + private void OnRebuildingIndexes(IndexRebuildingEventArgs args) => RebuildingIndexes?.Invoke(this, args); } } diff --git a/src/Umbraco.Examine/IndexRebuildingEventArgs.cs b/src/Umbraco.Examine/IndexRebuildingEventArgs.cs new file mode 100644 index 0000000000..20141a7194 --- /dev/null +++ b/src/Umbraco.Examine/IndexRebuildingEventArgs.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using Examine; + +namespace Umbraco.Examine +{ + public class IndexRebuildingEventArgs : EventArgs + { + public IndexRebuildingEventArgs(IEnumerable indexes) + { + Indexes = indexes; + } + + /// + /// The indexes being rebuilt + /// + public IEnumerable Indexes { get; } + } +} diff --git a/src/Umbraco.Web/Editors/ExamineManagementController.cs b/src/Umbraco.Web/Editors/ExamineManagementController.cs index b66dc0ed6a..2e1656b45d 100644 --- a/src/Umbraco.Web/Editors/ExamineManagementController.cs +++ b/src/Umbraco.Web/Editors/ExamineManagementController.cs @@ -5,7 +5,6 @@ using System.Net; using System.Net.Http; using System.Web.Http; using Examine; -using Examine.LuceneEngine.Providers; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.IO; @@ -24,17 +23,19 @@ namespace Umbraco.Web.Editors private readonly IExamineManager _examineManager; private readonly ILogger _logger; private readonly IIOHelper _ioHelper; + private readonly IIndexDiagnosticsFactory _indexDiagnosticsFactory; private readonly IAppPolicyCache _runtimeCache; private readonly IndexRebuilder _indexRebuilder; - public ExamineManagementController(IExamineManager examineManager, ILogger logger, IIOHelper ioHelper, + public ExamineManagementController(IExamineManager examineManager, ILogger logger, IIOHelper ioHelper, IIndexDiagnosticsFactory indexDiagnosticsFactory, AppCaches appCaches, IndexRebuilder indexRebuilder) { _examineManager = examineManager; _logger = logger; _ioHelper = ioHelper; + _indexDiagnosticsFactory = indexDiagnosticsFactory; _runtimeCache = appCaches.RuntimeCache; _indexRebuilder = indexRebuilder; } @@ -69,9 +70,8 @@ namespace Umbraco.Web.Editors if (!msg.IsSuccessStatusCode) throw new HttpResponseException(msg); - var results = global::Umbraco.Examine.ExamineExtensions.TryParseLuceneQuery(query) - ? searcher.CreateQuery().NativeQuery(query).Execute(maxResults: pageSize * (pageIndex + 1)) - : searcher.Search(query, maxResults: pageSize * (pageIndex + 1)); + // NativeQuery will work for a single word/phrase too (but depends on the implementation) the lucene one will work. + var results = searcher.CreateQuery().NativeQuery(query).Execute(maxResults: pageSize * (pageIndex + 1)); var pagedResults = results.Skip(pageIndex * pageSize); @@ -173,19 +173,11 @@ namespace Umbraco.Web.Editors } } - - private ExamineIndexModel CreateModel(IIndex index) { var indexName = index.Name; - if (!(index is IIndexDiagnostics indexDiag)) - { - if (index is LuceneIndex luceneIndex) - indexDiag = new LuceneIndexDiagnostics(luceneIndex, Logger, _ioHelper); - else - indexDiag = new GenericIndexDiagnostics(index); - } + var indexDiag = _indexDiagnosticsFactory.Create(index); var isHealth = indexDiag.IsHealthy(); var properties = new Dictionary diff --git a/src/Umbraco.Web/ExamineExtensions.cs b/src/Umbraco.Web/ExamineExtensions.cs index dd1277d3e2..5da21de6df 100644 --- a/src/Umbraco.Web/ExamineExtensions.cs +++ b/src/Umbraco.Web/ExamineExtensions.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Examine; -using Examine.LuceneEngine.Providers; using Umbraco.Core.Models.PublishedContent; using Umbraco.Examine; using Umbraco.Web.PublishedCache; diff --git a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs index 308605a197..c454f19ce7 100644 --- a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs +++ b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Examine; -using Examine.LuceneEngine.Providers; using Umbraco.Core; using Umbraco.Core.Mapping; using Umbraco.Core.Models; diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index d34398e066..1f4678e2e1 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -44,6 +44,7 @@ using Umbraco.Web.Trees; using Umbraco.Web.WebApi; using Current = Umbraco.Web.Composing.Current; using Umbraco.Web.PropertyEditors; +using Umbraco.Examine; namespace Umbraco.Web.Runtime { diff --git a/src/Umbraco.Web/Search/BackgroundIndexRebuilder.cs b/src/Umbraco.Web/Search/BackgroundIndexRebuilder.cs index 9f83b97393..2c964a2723 100644 --- a/src/Umbraco.Web/Search/BackgroundIndexRebuilder.cs +++ b/src/Umbraco.Web/Search/BackgroundIndexRebuilder.cs @@ -118,7 +118,6 @@ namespace Umbraco.Web.Search if (_waitMilliseconds > 0) Thread.Sleep(_waitMilliseconds); - _indexRebuilder.ExamineManager.ConfigureIndexes(_mainDom, _logger); _indexRebuilder.RebuildIndexes(_onlyEmptyIndexes); } } diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 416513d512..037981d8b4 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -13,9 +13,6 @@ using Umbraco.Core.Services.Changes; using Umbraco.Core.Sync; using Umbraco.Web.Cache; using Umbraco.Examine; -using Examine.LuceneEngine.Directories; -using Umbraco.Web.Composing; -using System.ComponentModel; namespace Umbraco.Web.Search { @@ -65,15 +62,6 @@ namespace Umbraco.Web.Search public void Initialize() { - //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the AppDomain - //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock - //which simply checks the existence of the lock file - DirectoryFactory.DefaultLockFactory = d => - { - var simpleFsLockFactory = new NoPrefixSimpleFsLockFactory(d); - return simpleFsLockFactory; - }; - //let's deal with shutting down Examine with MainDom var examineShutdownRegistered = _mainDom.Register(() => { diff --git a/src/Umbraco.Web/Search/ExamineComposer.cs b/src/Umbraco.Web/Search/ExamineComposer.cs index 9d8af5f3a0..fe3c604f8b 100644 --- a/src/Umbraco.Web/Search/ExamineComposer.cs +++ b/src/Umbraco.Web/Search/ExamineComposer.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Search composition.Register(Lifetime.Singleton); composition.RegisterUnique(); - composition.RegisterUnique(); + composition.RegisterUnique(); composition.RegisterUnique(factory => new ContentValueSetBuilder( factory.GetInstance(), diff --git a/src/Umbraco.Web/Search/ExamineFinalComponent.cs b/src/Umbraco.Web/Search/ExamineFinalComponent.cs index 95000b2b46..ffcd96af7e 100644 --- a/src/Umbraco.Web/Search/ExamineFinalComponent.cs +++ b/src/Umbraco.Web/Search/ExamineFinalComponent.cs @@ -12,15 +12,11 @@ namespace Umbraco.Web.Search /// public sealed class ExamineFinalComponent : IComponent { - private readonly IProfilingLogger _logger; - private readonly IExamineManager _examineManager; BackgroundIndexRebuilder _indexRebuilder; private readonly IMainDom _mainDom; - public ExamineFinalComponent(IProfilingLogger logger, IExamineManager examineManager, BackgroundIndexRebuilder indexRebuilder, IMainDom mainDom) + public ExamineFinalComponent(BackgroundIndexRebuilder indexRebuilder, IMainDom mainDom) { - _logger = logger; - _examineManager = examineManager; _indexRebuilder = indexRebuilder; _mainDom = mainDom; } @@ -29,8 +25,6 @@ namespace Umbraco.Web.Search { if (!_mainDom.IsMainDom) return; - _examineManager.ConfigureIndexes(_mainDom, _logger); - // TODO: Instead of waiting 5000 ms, we could add an event handler on to fulfilling the first request, then start? _indexRebuilder.RebuildIndexes(true, 5000); } diff --git a/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs b/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs index 306d4c0593..0f52384409 100644 --- a/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs +++ b/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Text.RegularExpressions; using Examine; using Umbraco.Core; using Umbraco.Core.Mapping; @@ -22,29 +20,26 @@ namespace Umbraco.Web.Search /// public class UmbracoTreeSearcher { - private readonly IExamineManager _examineManager; private readonly UmbracoContext _umbracoContext; private readonly ILocalizationService _languageService; private readonly IEntityService _entityService; private readonly UmbracoMapper _mapper; private readonly ISqlContext _sqlContext; - private readonly IUmbracoTreeSearcherFields _umbracoTreeSearcherFields; + private readonly IBackOfficeExamineSearcher _backOfficeExamineSearcher; - public UmbracoTreeSearcher(IExamineManager examineManager, - UmbracoContext umbracoContext, + public UmbracoTreeSearcher(UmbracoContext umbracoContext, ILocalizationService languageService, IEntityService entityService, UmbracoMapper mapper, - ISqlContext sqlContext,IUmbracoTreeSearcherFields umbracoTreeSearcherFields) + ISqlContext sqlContext, IBackOfficeExamineSearcher backOfficeExamineSearcher) { - _examineManager = examineManager ?? throw new ArgumentNullException(nameof(examineManager)); _umbracoContext = umbracoContext; _languageService = languageService; _entityService = entityService; _mapper = mapper; _sqlContext = sqlContext; - _umbracoTreeSearcherFields = umbracoTreeSearcherFields; + _backOfficeExamineSearcher = backOfficeExamineSearcher; } /// @@ -66,72 +61,7 @@ namespace Umbraco.Web.Search int pageSize, long pageIndex, out long totalFound, string searchFrom = null, bool ignoreUserStartNodes = false) { - var sb = new StringBuilder(); - - string type; - var indexName = Constants.UmbracoIndexes.InternalIndexName; - var fields = _umbracoTreeSearcherFields.GetBackOfficeFields().ToList(); - - // TODO: WE should try to allow passing in a lucene raw query, however we will still need to do some manual string - // manipulation for things like start paths, member types, etc... - //if (Examine.ExamineExtensions.TryParseLuceneQuery(query)) - //{ - - //} - - //special GUID check since if a user searches on one specifically we need to escape it - if (Guid.TryParse(query, out var g)) - { - query = "\"" + g.ToString() + "\""; - } - - switch (entityType) - { - case UmbracoEntityTypes.Member: - indexName = Constants.UmbracoIndexes.MembersIndexName; - type = "member"; - fields.AddRange(_umbracoTreeSearcherFields.GetBackOfficeMembersFields()); - if (searchFrom != null && searchFrom != Constants.Conventions.MemberTypes.AllMembersListId && searchFrom.Trim() != "-1") - { - sb.Append("+__NodeTypeAlias:"); - sb.Append(searchFrom); - sb.Append(" "); - } - break; - case UmbracoEntityTypes.Media: - type = "media"; - fields.AddRange(_umbracoTreeSearcherFields.GetBackOfficeMediaFields()); - var allMediaStartNodes = _umbracoContext.Security.CurrentUser.CalculateMediaStartNodeIds(_entityService); - AppendPath(sb, UmbracoObjectTypes.Media, allMediaStartNodes, searchFrom, ignoreUserStartNodes, _entityService); - break; - case UmbracoEntityTypes.Document: - type = "content"; - fields.AddRange(_umbracoTreeSearcherFields.GetBackOfficeDocumentFields()); - var allContentStartNodes = _umbracoContext.Security.CurrentUser.CalculateContentStartNodeIds(_entityService); - AppendPath(sb, UmbracoObjectTypes.Document, allContentStartNodes, searchFrom, ignoreUserStartNodes, _entityService); - break; - default: - throw new NotSupportedException("The " + typeof(UmbracoTreeSearcher) + " currently does not support searching against object type " + entityType); - } - - if (!_examineManager.TryGetIndex(indexName, out var index)) - throw new InvalidOperationException("No index found by name " + indexName); - - var internalSearcher = index.GetSearcher(); - - if (!BuildQuery(sb, query, searchFrom, fields, type)) - { - totalFound = 0; - return Enumerable.Empty(); - } - - var result = internalSearcher.CreateQuery().NativeQuery(sb.ToString()) - //only return the number of items specified to read up to the amount of records to fill from 0 -> the number of items on the page requested - .Execute(Convert.ToInt32(pageSize * (pageIndex + 1))); - - totalFound = result.TotalItemCount; - - var pagedResult = result.Skip(Convert.ToInt32(pageIndex)); + var pagedResult = _backOfficeExamineSearcher.Search(query, entityType, pageSize, pageIndex, out totalFound, searchFrom, ignoreUserStartNodes); switch (entityType) { @@ -166,236 +96,6 @@ namespace Umbraco.Web.Search return _mapper.MapEnumerable(results); } - private bool BuildQuery(StringBuilder sb, string query, string searchFrom, List fields, string type) - { - //build a lucene query: - // the nodeName will be boosted 10x without wildcards - // then nodeName will be matched normally with wildcards - // the rest will be normal without wildcards - - var allLangs = _languageService.GetAllLanguages().Select(x => x.IsoCode.ToLowerInvariant()).ToList(); - - //check if text is surrounded by single or double quotes, if so, then exact match - var surroundedByQuotes = Regex.IsMatch(query, "^\".*?\"$") - || Regex.IsMatch(query, "^\'.*?\'$"); - - if (surroundedByQuotes) - { - //strip quotes, escape string, the replace again - query = query.Trim('\"', '\''); - - query = Lucene.Net.QueryParsers.QueryParser.Escape(query); - - //nothing to search - if (searchFrom.IsNullOrWhiteSpace() && query.IsNullOrWhiteSpace()) - { - return false; - } - - //update the query with the query term - if (query.IsNullOrWhiteSpace() == false) - { - //add back the surrounding quotes - query = string.Format("{0}{1}{0}", "\"", query); - - sb.Append("+("); - - AppendNodeNamePhraseWithBoost(sb, query, allLangs); - - foreach (var f in fields) - { - //additional fields normally - sb.Append(f); - sb.Append(": ("); - sb.Append(query); - sb.Append(") "); - } - - sb.Append(") "); - } - } - else - { - var trimmed = query.Trim(new[] { '\"', '\'' }); - - //nothing to search - if (searchFrom.IsNullOrWhiteSpace() && trimmed.IsNullOrWhiteSpace()) - { - return false; - } - - //update the query with the query term - if (trimmed.IsNullOrWhiteSpace() == false) - { - query = Lucene.Net.QueryParsers.QueryParser.Escape(query); - - var querywords = query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - - sb.Append("+("); - - AppendNodeNameExactWithBoost(sb, query, allLangs); - - AppendNodeNameWithWildcards(sb, querywords, allLangs); - - foreach (var f in fields) - { - var queryWordsReplaced = new string[querywords.Length]; - - // when searching file names containing hyphens we need to replace the hyphens with spaces - if (f.Equals(UmbracoExamineFieldNames.UmbracoFileFieldName)) - { - for (var index = 0; index < querywords.Length; index++) - { - queryWordsReplaced[index] = querywords[index].Replace("\\-", " ").Replace("_", " ").Trim(" "); - } - } - else - { - queryWordsReplaced = querywords; - } - - //additional fields normally - sb.Append(f); - sb.Append(":"); - sb.Append("("); - foreach (var w in queryWordsReplaced) - { - sb.Append(w.ToLower()); - sb.Append("* "); - } - sb.Append(")"); - sb.Append(" "); - } - - sb.Append(") "); - } - } - - //must match index type - sb.Append("+__IndexType:"); - sb.Append(type); - - return true; - } - - private void AppendNodeNamePhraseWithBoost(StringBuilder sb, string query, IEnumerable allLangs) - { - //node name exactly boost x 10 - sb.Append("nodeName: ("); - sb.Append(query.ToLower()); - sb.Append(")^10.0 "); - - //also search on all variant node names - foreach (var lang in allLangs) - { - //node name exactly boost x 10 - sb.Append($"nodeName_{lang}: ("); - sb.Append(query.ToLower()); - sb.Append(")^10.0 "); - } - } - - private void AppendNodeNameExactWithBoost(StringBuilder sb, string query, IEnumerable allLangs) - { - //node name exactly boost x 10 - sb.Append("nodeName:"); - sb.Append("\""); - sb.Append(query.ToLower()); - sb.Append("\""); - sb.Append("^10.0 "); - //also search on all variant node names - foreach (var lang in allLangs) - { - //node name exactly boost x 10 - sb.Append($"nodeName_{lang}:"); - sb.Append("\""); - sb.Append(query.ToLower()); - sb.Append("\""); - sb.Append("^10.0 "); - } - } - - private void AppendNodeNameWithWildcards(StringBuilder sb, string[] querywords, IEnumerable allLangs) - { - //node name normally with wildcards - sb.Append("nodeName:"); - sb.Append("("); - foreach (var w in querywords) - { - sb.Append(w.ToLower()); - sb.Append("* "); - } - sb.Append(") "); - //also search on all variant node names - foreach (var lang in allLangs) - { - //node name normally with wildcards - sb.Append($"nodeName_{lang}:"); - sb.Append("("); - foreach (var w in querywords) - { - sb.Append(w.ToLower()); - sb.Append("* "); - } - sb.Append(") "); - } - } - - private void AppendPath(StringBuilder sb, UmbracoObjectTypes objectType, int[] startNodeIds, string searchFrom, bool ignoreUserStartNodes, IEntityService entityService) - { - if (sb == null) throw new ArgumentNullException(nameof(sb)); - if (entityService == null) throw new ArgumentNullException(nameof(entityService)); - - UdiParser.TryParse(searchFrom, true, out var udi); - searchFrom = udi == null ? searchFrom : entityService.GetId(udi).Result.ToString(); - - var entityPath = int.TryParse(searchFrom, out var searchFromId) && searchFromId > 0 - ? entityService.GetAllPaths(objectType, searchFromId).FirstOrDefault() - : null; - if (entityPath != null) - { - // find... only what's underneath - sb.Append("+__Path:"); - AppendPath(sb, entityPath.Path, false); - sb.Append(" "); - } - else if (startNodeIds.Length == 0) - { - // make sure we don't find anything - sb.Append("+__Path:none "); - } - else if (startNodeIds.Contains(-1) == false && ignoreUserStartNodes == false) // -1 = no restriction - { - var entityPaths = entityService.GetAllPaths(objectType, startNodeIds); - - // for each start node, find the start node, and what's underneath - // +__Path:(-1*,1234 -1*,1234,* -1*,5678 -1*,5678,* ...) - sb.Append("+__Path:("); - var first = true; - foreach (var ep in entityPaths) - { - if (first) - first = false; - else - sb.Append(" "); - AppendPath(sb, ep.Path, true); - } - sb.Append(") "); - } - } - - private void AppendPath(StringBuilder sb, string path, bool includeThisNode) - { - path = path.Replace("-", "\\-").Replace(",", "\\,"); - if (includeThisNode) - { - sb.Append(path); - sb.Append(" "); - } - sb.Append(path); - sb.Append("\\,*"); - } - /// /// Returns a collection of entities for media based on search results /// diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 9d226cda3d..d285e7e587 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -65,9 +65,6 @@ 2.0.0-alpha.20200128.15 - - 2.0.0-alpha.20200128.15 - 2.7.0.100 @@ -116,10 +113,6 @@ {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} Umbraco.Examine - - {07fbc26b-2927-4a22-8d96-d644c667fecc} - Umbraco.Examine.Lucene - {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure @@ -246,7 +239,6 @@ - @@ -271,9 +263,6 @@ - - - From 76d868d46d5bcf9873a1af8957937972937db088 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Jan 2020 12:31:06 +1100 Subject: [PATCH 08/16] Moves file --- src/Umbraco.Examine/BaseValueSetBuilder.cs | 1 - src/Umbraco.Examine/IIndexDiagnostics.cs | 3 +-- .../Search => Umbraco.Examine}/IUmbracoTreeSearcherFields.cs | 0 3 files changed, 1 insertion(+), 3 deletions(-) rename src/{Umbraco.Abstractions/Search => Umbraco.Examine}/IUmbracoTreeSearcherFields.cs (100%) diff --git a/src/Umbraco.Examine/BaseValueSetBuilder.cs b/src/Umbraco.Examine/BaseValueSetBuilder.cs index 4a306aa5ff..2350d3cb84 100644 --- a/src/Umbraco.Examine/BaseValueSetBuilder.cs +++ b/src/Umbraco.Examine/BaseValueSetBuilder.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using Examine; using Umbraco.Core; using Umbraco.Core.Models; diff --git a/src/Umbraco.Examine/IIndexDiagnostics.cs b/src/Umbraco.Examine/IIndexDiagnostics.cs index b51f6f256f..fa9dde25b8 100644 --- a/src/Umbraco.Examine/IIndexDiagnostics.cs +++ b/src/Umbraco.Examine/IIndexDiagnostics.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Umbraco.Core; namespace Umbraco.Examine diff --git a/src/Umbraco.Abstractions/Search/IUmbracoTreeSearcherFields.cs b/src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs similarity index 100% rename from src/Umbraco.Abstractions/Search/IUmbracoTreeSearcherFields.cs rename to src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs From 1dffffcf1149e5270c12a85491148924151ce83c Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Jan 2020 12:36:57 +1100 Subject: [PATCH 09/16] changes namesapces --- src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs | 1 - src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs | 1 - src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs | 5 ++--- src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs index 71d192146b..7b756f3dfc 100644 --- a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs +++ b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs @@ -10,7 +10,6 @@ using Umbraco.Core.Models.Identity; using Umbraco.Core.Persistence; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; -using Umbraco.Web.Search; namespace Umbraco.Examine { diff --git a/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs b/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs index 0334531691..724149a01d 100644 --- a/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs +++ b/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs @@ -1,6 +1,5 @@ using Umbraco.Core; using Umbraco.Core.Composing; -using Umbraco.Web.Search; namespace Umbraco.Examine { diff --git a/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs b/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs index 8e50c6ebc4..173300a472 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Umbraco.Core.Logging; using Umbraco.Core.Services; -using Umbraco.Examine; using Lucene.Net.Analysis.Standard; using Examine.LuceneEngine; using Examine; @@ -9,7 +8,7 @@ using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.IO; -namespace Umbraco.Web.Search +namespace Umbraco.Examine { /// /// Creates the indexes used by Umbraco @@ -51,7 +50,7 @@ namespace Umbraco.Web.Search /// public override IEnumerable Create() { - return new [] + return new[] { CreateInternalIndex(), CreateExternalIndex(), diff --git a/src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs b/src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs index fdbf5bf60d..d873d01972 100644 --- a/src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs +++ b/src/Umbraco.Examine/IUmbracoTreeSearcherFields.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -namespace Umbraco.Web.Search -{ +namespace Umbraco.Examine +{ /// /// Used to propagate hardcoded internal Field lists /// From a19d9b2a9b10f97122ddc62c18aec5b7ec0f6c29 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Jan 2020 12:42:50 +1100 Subject: [PATCH 10/16] removes empty file --- .../Umbraco.Examine.Lucene.csproj | 1 - .../UmbracoExamineExtensions.cs | 13 ------------- 2 files changed, 14 deletions(-) delete mode 100644 src/Umbraco.Examine.Lucene/UmbracoExamineExtensions.cs diff --git a/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj index 255df2d2d6..f91cc02a71 100644 --- a/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj +++ b/src/Umbraco.Examine.Lucene/Umbraco.Examine.Lucene.csproj @@ -74,7 +74,6 @@ - diff --git a/src/Umbraco.Examine.Lucene/UmbracoExamineExtensions.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineExtensions.cs deleted file mode 100644 index 7de6dbed9c..0000000000 --- a/src/Umbraco.Examine.Lucene/UmbracoExamineExtensions.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Examine.LuceneEngine.Search; -using Examine.Search; -using Umbraco.Core; - -namespace Umbraco.Examine -{ - public static class UmbracoExamineExtensions - { - - - - } -} From ecf5a5efbcae23a01cdc4ba79b8d2a9dd4a068d2 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Jan 2020 12:46:16 +1100 Subject: [PATCH 11/16] reverts accidental change --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 2668b38006..527d5bca37 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -343,6 +343,9 @@ False True + 9000 + / + http://localhost:9000/ 8700 / http://localhost:8700 From 958118fc7f56d80789ca8c15a7ec8bfe24d4c3a1 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Jan 2020 14:20:17 +1100 Subject: [PATCH 12/16] removes duplicate lines in csproj --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 527d5bca37..5e0d5d0973 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -345,10 +345,7 @@ True 9000 / - http://localhost:9000/ - 8700 - / - http://localhost:8700 + http://localhost:9000/ False False @@ -430,4 +427,4 @@ - \ No newline at end of file + From 5259b19eef0e108ad89149ecb328a3f153c7f807 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 30 Jan 2020 19:19:19 +0100 Subject: [PATCH 13/16] Fix reference to umbraco.core --- build/NuSpecs/tools/serilog.config.install.xdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/NuSpecs/tools/serilog.config.install.xdt b/build/NuSpecs/tools/serilog.config.install.xdt index e0df2985c7..b4a10b7bc2 100644 --- a/build/NuSpecs/tools/serilog.config.install.xdt +++ b/build/NuSpecs/tools/serilog.config.install.xdt @@ -2,7 +2,7 @@ > - + From 8cb11de18c6f7c52544b103732c925808b46b56c Mon Sep 17 00:00:00 2001 From: Emma Garland Date: Fri, 31 Jan 2020 13:51:22 +0000 Subject: [PATCH 14/16] Replaced member service and user service with mocks --- .../Cache/PublishedCache/PublishedContentCacheTests.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs index 00fc5b09b8..0f9570ffd8 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs @@ -4,7 +4,6 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Web.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Services; @@ -70,7 +69,7 @@ namespace Umbraco.Tests.Cache.PublishedCache var publishedShapshot = new PublishedSnapshot( new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, VariationContextAccessor, null), new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance(), umbracoContextAccessor, VariationContextAccessor), - new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, Current.Services.UserService, VariationContextAccessor), + new PublishedMemberCache(null, appCache, Mock.Of(), ContentTypesCache, Mock.Of(), VariationContextAccessor), domainCache); var publishedSnapshotService = new Mock(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedShapshot); @@ -78,7 +77,7 @@ namespace Umbraco.Tests.Cache.PublishedCache _umbracoContext = new UmbracoContext( _httpContextFactory.HttpContext, publishedSnapshotService.Object, - new WebSecurity(_httpContextFactory.HttpContext, Current.Services.UserService, globalSettings), + new WebSecurity(_httpContextFactory.HttpContext, Mock.Of(), globalSettings), umbracoSettings, Enumerable.Empty(), Enumerable.Empty(), From e303d9e4f4e9ecaea011ccb7a081b198012a9625 Mon Sep 17 00:00:00 2001 From: Emma Garland Date: Fri, 31 Jan 2020 13:57:23 +0000 Subject: [PATCH 15/16] Mock IMediaService and IUserService --- .../Cache/PublishedCache/PublishedContentCacheTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs index 0f9570ffd8..7ef4495ad2 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs @@ -65,10 +65,10 @@ namespace Umbraco.Tests.Cache.PublishedCache _xml.LoadXml(GetXml()); var xmlStore = new XmlStore(() => _xml, null, null, null, HostingEnvironment); var appCache = new DictionaryAppCache(); - var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor); + var domainCache = new DomainCache(Mock.Of(), DefaultCultureAccessor); var publishedShapshot = new PublishedSnapshot( new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, VariationContextAccessor, null), - new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance(), umbracoContextAccessor, VariationContextAccessor), + new PublishedMediaCache(xmlStore, Mock.Of(), Mock.Of(), appCache, ContentTypesCache, Factory.GetInstance(), umbracoContextAccessor, VariationContextAccessor), new PublishedMemberCache(null, appCache, Mock.Of(), ContentTypesCache, Mock.Of(), VariationContextAccessor), domainCache); var publishedSnapshotService = new Mock(); From 0c619b184e26b72d6f623338fd4c8ca0eac2a27b Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 4 Feb 2020 12:39:03 +1100 Subject: [PATCH 16/16] remove comments --- src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs index 7b756f3dfc..cfa9de5fa6 100644 --- a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs +++ b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs @@ -42,13 +42,6 @@ namespace Umbraco.Examine var indexName = Constants.UmbracoIndexes.InternalIndexName; var fields = _treeSearcherFields.GetBackOfficeFields().ToList(); - // TODO: WE should try to allow passing in a lucene raw query, however we will still need to do some manual string - // manipulation for things like start paths, member types, etc... - //if (Examine.ExamineExtensions.TryParseLuceneQuery(query)) - //{ - - //} - //special GUID check since if a user searches on one specifically we need to escape it if (Guid.TryParse(query, out var g)) {