more bug fixes

This commit is contained in:
Shannon
2018-12-13 22:33:41 +11:00
parent 2060f69ab0
commit c129375dd0
8 changed files with 72 additions and 91 deletions

View File

@@ -25,7 +25,7 @@
<dependency id="ClientDependency" version="[1.9.7,1.999999)" />
<dependency id="ClientDependency-Mvc5" version="[1.8.0,1.999999)" />
<dependency id="CSharpTest.Net.Collections" version="[14.906.1403.1082,14.999999)" />
<dependency id="Examine" version="[1.0.0-beta055,1.999999)" />
<dependency id="Examine" version="[1.0.0-beta060,1.999999)" />
<dependency id="HtmlAgilityPack" version="[1.8.9,1.999999)" />
<dependency id="ImageProcessor" version="[2.6.2.25,2.999999)" />
<dependency id="LightInject.Mvc" version="[2.0.0,2.999999)" />

View File

@@ -48,7 +48,7 @@
</ItemGroup>
<ItemGroup>
<!-- note: NuGet deals with transitive references now -->
<PackageReference Include="Examine" Version="1.0.0-beta055" />
<PackageReference Include="Examine" Version="1.0.0-beta059" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NPoco" Version="3.9.4" />
</ItemGroup>
@@ -90,6 +90,7 @@
<Compile Include="UmbracoExamineIndex.cs" />
<Compile Include="UmbracoExamineSearcher.cs" />
<Compile Include="LuceneIndexCreator.cs" />
<Compile Include="UmbracoFieldDefinitionCollection.cs" />
<Compile Include="UmbracoMemberIndex.cs" />
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>

View File

@@ -18,45 +18,6 @@ using Examine.LuceneEngine;
namespace Umbraco.Examine
{
/// <summary>
/// Custom <see cref="FieldDefinitionCollection"/> allowing dynamic creation of <see cref="FieldDefinition"/>
/// </summary>
public class UmbracoFieldDefinitionCollection : FieldDefinitionCollection
{
public UmbracoFieldDefinitionCollection()
: base(UmbracoExamineIndex.UmbracoIndexFieldDefinitions)
{
}
///// <summary>
///// Overridden to dynamically add field definitions for culture variations
///// </summary>
///// <param name="fieldName"></param>
///// <param name="fieldDefinition"></param>
///// <returns></returns>
//public override bool TryGetValue(string fieldName, out FieldDefinition fieldDefinition)
//{
// var result = base.TryGetValue(fieldName, out fieldDefinition);
// if (result) return true;
// //if the fieldName is not suffixed with _iso-Code
// var underscoreIndex = fieldName.LastIndexOf('_');
// if (underscoreIndex == -1) return false;
// var isoCode = fieldName.Substring(underscoreIndex);
// if (isoCode.Length < 6) return false; //invalid isoCode
// var hyphenIndex = isoCode.IndexOf('-');
// if (hyphenIndex != 3) return false; //invalid isoCode
// //we'll assume this is a valid isoCode
//}
}
/// <summary>
/// An indexer for Umbraco content and media
/// </summary>
@@ -161,7 +122,7 @@ namespace Umbraco.Examine
//anywhere else in this class
Current.Services.PublicAccessService,
parentId,
ConfigIndexCriteria.IncludeItemTypes, ConfigIndexCriteria.ExcludeItemTypes);
ConfigIndexCriteria?.IncludeItemTypes, ConfigIndexCriteria?.ExcludeItemTypes);
PublishedValuesOnly = supportUnpublished;
}

View File

@@ -20,8 +20,7 @@ namespace Umbraco.Examine
{
/// <summary>
/// An abstract provider containing the basic functionality to be able to query against
/// Umbraco data.
/// An abstract provider containing the basic functionality to be able to query against Umbraco data.
/// </summary>
public abstract class UmbracoExamineIndex : LuceneIndex, IUmbracoIndex, IIndexDiagnostics
{
@@ -53,6 +52,7 @@ namespace Umbraco.Examine
{
ProfilingLogger = Current.ProfilingLogger;
_configBased = true;
_diagnostics = new UmbracoExamineIndexDiagnostics(this, ProfilingLogger.Logger);
}
/// <summary>
@@ -120,26 +120,6 @@ namespace Umbraco.Examine
protected ProfilingLogger ProfilingLogger { get; }
/// <summary>
/// Overridden to ensure that the umbraco system field definitions are in place
/// </summary>
/// <param name="indexValueTypesFactory"></param>
/// <returns></returns>
protected override FieldValueTypeCollection CreateFieldValueTypes(IReadOnlyDictionary<string, IFieldValueTypeFactory> indexValueTypesFactory = null)
{
//if config based then ensure the value types else it's assumed these were passed in via ctor
if (_configBased)
{
foreach (var field in UmbracoIndexFieldDefinitions)
{
FieldDefinitionCollection.TryAdd(field);
}
}
return base.CreateFieldValueTypes(indexValueTypesFactory);
}
/// <summary>
/// When set to true Umbraco will keep the index in sync with Umbraco data automatically
/// </summary>
@@ -174,12 +154,15 @@ namespace Umbraco.Examine
EnableDefaultEventHandler = enabled;
}
//Need to check if the index set or IndexerData is specified...
if (config["indexSet"] == null && FieldDefinitionCollection.Count == 0)
//this is config based, so add the default definitions
foreach (var field in UmbracoIndexFieldDefinitions)
{
//if we don't have either, then we'll try to set the index set by naming conventions
var found = false;
FieldDefinitionCollection.TryAdd(field);
}
//Need to check if the index set is specified...
if (config["indexSet"] == null)
{
var possibleSuffixes = new[] {"Index", "Indexer"};
foreach (var suffix in possibleSuffixes)
{
@@ -200,36 +183,29 @@ namespace Umbraco.Examine
ConfigIndexCriteria = CreateFieldDefinitionsFromConfig(indexSet);
foreach (var fieldDefinition in ConfigIndexCriteria.StandardFields.Union(ConfigIndexCriteria.UserFields))
{
FieldDefinitionCollection.TryAdd(fieldDefinition);
//replace any existing or add
FieldDefinitionCollection.AddOrUpdate(fieldDefinition);
}
found = true;
break;
}
if (!found)
throw new ArgumentNullException("indexSet on LuceneExamineIndexer provider has not been set in configuration and/or the IndexerData property has not been explicitly set");
}
else if (config["indexSet"] != null)
else
{
//if an index set is specified, ensure it exists and initialize the indexer based on the set
if (IndexSets.Instance.Sets[config["indexSet"]] == null)
{
throw new ArgumentException("The indexSet specified for the LuceneExamineIndexer provider does not exist");
}
else
IndexSetName = config["indexSet"];
var indexSet = IndexSets.Instance.Sets[IndexSetName];
//get the index criteria and ensure folder
ConfigIndexCriteria = CreateFieldDefinitionsFromConfig(indexSet);
foreach (var fieldDefinition in ConfigIndexCriteria.StandardFields.Union(ConfigIndexCriteria.UserFields))
{
IndexSetName = config["indexSet"];
var indexSet = IndexSets.Instance.Sets[IndexSetName];
//get the index criteria and ensure folder
ConfigIndexCriteria = CreateFieldDefinitionsFromConfig(indexSet);
foreach (var fieldDefinition in ConfigIndexCriteria.StandardFields.Union(ConfigIndexCriteria.UserFields))
{
FieldDefinitionCollection.TryAdd(fieldDefinition);
}
//replace any existing or add
FieldDefinitionCollection.AddOrUpdate(fieldDefinition);
}
}

View File

@@ -0,0 +1,43 @@
using Examine;
namespace Umbraco.Examine
{
/// <summary>
/// Custom <see cref="FieldDefinitionCollection"/> allowing dynamic creation of <see cref="FieldDefinition"/>
/// </summary>
public class UmbracoFieldDefinitionCollection : FieldDefinitionCollection
{
public UmbracoFieldDefinitionCollection()
: base(UmbracoExamineIndex.UmbracoIndexFieldDefinitions)
{
}
///// <summary>
///// Overridden to dynamically add field definitions for culture variations
///// </summary>
///// <param name="fieldName"></param>
///// <param name="fieldDefinition"></param>
///// <returns></returns>
//public override bool TryGetValue(string fieldName, out FieldDefinition fieldDefinition)
//{
// var result = base.TryGetValue(fieldName, out fieldDefinition);
// if (result) return true;
// //if the fieldName is not suffixed with _iso-Code
// var underscoreIndex = fieldName.LastIndexOf('_');
// if (underscoreIndex == -1) return false;
// var isoCode = fieldName.Substring(underscoreIndex);
// if (isoCode.Length < 6) return false; //invalid isoCode
// var hyphenIndex = isoCode.IndexOf('-');
// if (hyphenIndex != 3) return false; //invalid isoCode
// //we'll assume this is a valid isoCode
//}
}
}

View File

@@ -77,7 +77,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="7.0.1" />
<PackageReference Include="Castle.Core" Version="4.2.1" />
<PackageReference Include="Examine" Version="1.0.0-beta055" />
<PackageReference Include="Examine" Version="1.0.0-beta059" />
<PackageReference Include="HtmlAgilityPack">
<Version>1.8.9</Version>
</PackageReference>

View File

@@ -88,7 +88,7 @@
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
<PackageReference Include="ClientDependency" Version="1.9.7" />
<PackageReference Include="ClientDependency-Mvc5" Version="1.8.0.0" />
<PackageReference Include="Examine" Version="1.0.0-beta055" />
<PackageReference Include="Examine" Version="1.0.0-beta059" />
<PackageReference Include="ImageProcessor.Web" Version="4.9.3.25" />
<PackageReference Include="ImageProcessor.Web.Config" Version="2.4.1.19" />
<PackageReference Include="Microsoft.AspNet.Identity.Owin" Version="2.2.2" />

View File

@@ -62,7 +62,7 @@
<PackageReference Include="AutoMapper" Version="7.0.1" />
<PackageReference Include="ClientDependency" Version="1.9.7" />
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
<PackageReference Include="Examine" Version="1.0.0-beta055" />
<PackageReference Include="Examine" Version="1.0.0-beta059" />
<PackageReference Include="HtmlAgilityPack" Version="1.8.9" />
<PackageReference Include="ImageProcessor">
<Version>2.6.2.25</Version>