Update examine to version 3 (#12307)
* Updating to Examine 3 beta. Currently not building due to missing support for updating values in the OnTransformingIndexValues event * Updated to beta 6 - It builds, but we need to fix tests * Fixed issue with values being passed into nested lists. * Fixed issue in test * Updated to examine beta.9 * Fixed breaking changes
This commit is contained in:
@@ -98,22 +98,24 @@ namespace Umbraco.Cms.Infrastructure.Examine
|
||||
public override ValueSetValidationResult Validate(ValueSet valueSet)
|
||||
{
|
||||
var baseValidate = base.Validate(valueSet);
|
||||
if (baseValidate == ValueSetValidationResult.Failed)
|
||||
return ValueSetValidationResult.Failed;
|
||||
valueSet = baseValidate.ValueSet;
|
||||
if (baseValidate.Status == ValueSetValidationStatus.Failed)
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
|
||||
var isFiltered = baseValidate == ValueSetValidationResult.Filtered;
|
||||
var isFiltered = baseValidate.Status == ValueSetValidationStatus.Filtered;
|
||||
|
||||
var filteredValues = valueSet.Values.ToDictionary(x => x.Key, x => x.Value.ToList());
|
||||
//check for published content
|
||||
if (valueSet.Category == IndexTypes.Content && PublishedValuesOnly)
|
||||
{
|
||||
if (!valueSet.Values.TryGetValue(UmbracoExamineFieldNames.PublishedFieldName, out var published))
|
||||
{
|
||||
return ValueSetValidationResult.Failed;
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
}
|
||||
|
||||
if (!published[0].Equals("y"))
|
||||
{
|
||||
return ValueSetValidationResult.Failed;
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
}
|
||||
|
||||
//deal with variants, if there are unpublished variants than we need to remove them from the value set
|
||||
@@ -129,7 +131,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
|
||||
var cultureSuffix = publishField.Key.Substring(publishField.Key.LastIndexOf('_'));
|
||||
foreach (var cultureField in valueSet.Values.Where(x => x.Key.InvariantEndsWith(cultureSuffix)).ToList())
|
||||
{
|
||||
valueSet.Values.Remove(cultureField.Key);
|
||||
filteredValues.Remove(cultureField.Key);
|
||||
isFiltered = true;
|
||||
}
|
||||
}
|
||||
@@ -138,21 +140,22 @@ namespace Umbraco.Cms.Infrastructure.Examine
|
||||
}
|
||||
|
||||
//must have a 'path'
|
||||
if (!valueSet.Values.TryGetValue(PathKey, out var pathValues)) return ValueSetValidationResult.Failed;
|
||||
if (pathValues.Count == 0) return ValueSetValidationResult.Failed;
|
||||
if (pathValues[0] == null) return ValueSetValidationResult.Failed;
|
||||
if (pathValues[0].ToString().IsNullOrWhiteSpace()) return ValueSetValidationResult.Failed;
|
||||
if (!valueSet.Values.TryGetValue(PathKey, out var pathValues)) return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
if (pathValues.Count == 0) return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
if (pathValues[0] == null) return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
if (pathValues[0].ToString().IsNullOrWhiteSpace()) return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
var path = pathValues[0].ToString();
|
||||
|
||||
var filteredValueSet = new ValueSet(valueSet.Id, valueSet.Category, valueSet.ItemType, filteredValues.ToDictionary(x=>x.Key, x=> (IEnumerable<object>)x.Value));
|
||||
// We need to validate the path of the content based on ParentId, protected content and recycle bin rules.
|
||||
// We cannot return FAILED here because we need the value set to get into the indexer and then deal with it from there
|
||||
// because we need to remove anything that doesn't pass by protected content in the cases that umbraco data is moved to an illegal parent.
|
||||
if (!ValidatePath(path!, valueSet.Category)
|
||||
|| !ValidateRecycleBin(path!, valueSet.Category)
|
||||
|| !ValidateProtectedContent(path!, valueSet.Category))
|
||||
return ValueSetValidationResult.Filtered;
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Filtered, filteredValueSet);
|
||||
|
||||
return isFiltered ? ValueSetValidationResult.Filtered : ValueSetValidationResult.Valid;
|
||||
return new ValueSetValidationResult(isFiltered ? ValueSetValidationStatus.Filtered : ValueSetValidationStatus.Valid, filteredValueSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,18 +60,19 @@ namespace Umbraco.Cms.Infrastructure.Examine
|
||||
public virtual ValueSetValidationResult Validate(ValueSet valueSet)
|
||||
{
|
||||
if (ValidIndexCategories != null && !ValidIndexCategories.InvariantContains(valueSet.Category))
|
||||
return ValueSetValidationResult.Failed;
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
|
||||
//check if this document is of a correct type of node type alias
|
||||
if (IncludeItemTypes != null && !IncludeItemTypes.InvariantContains(valueSet.ItemType))
|
||||
return ValueSetValidationResult.Failed;
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
|
||||
//if this node type is part of our exclusion list
|
||||
if (ExcludeItemTypes != null && ExcludeItemTypes.InvariantContains(valueSet.ItemType))
|
||||
return ValueSetValidationResult.Failed;
|
||||
return new ValueSetValidationResult(ValueSetValidationStatus.Failed, valueSet);
|
||||
|
||||
var isFiltered = false;
|
||||
|
||||
var filteredValues = valueSet.Values.ToDictionary(x => x.Key, x => x.Value.ToList());
|
||||
//filter based on the fields provided (if any)
|
||||
if (IncludeFields != null || ExcludeFields != null)
|
||||
{
|
||||
@@ -79,20 +80,21 @@ namespace Umbraco.Cms.Infrastructure.Examine
|
||||
{
|
||||
if (IncludeFields != null && !IncludeFields.InvariantContains(key))
|
||||
{
|
||||
valueSet.Values.Remove(key); //remove any value with a key that doesn't match the inclusion list
|
||||
filteredValues.Remove(key); //remove any value with a key that doesn't match the inclusion list
|
||||
isFiltered = true;
|
||||
}
|
||||
|
||||
if (ExcludeFields != null && ExcludeFields.InvariantContains(key))
|
||||
{
|
||||
valueSet.Values.Remove(key); //remove any value with a key that matches the exclusion list
|
||||
filteredValues.Remove(key); //remove any value with a key that matches the exclusion list
|
||||
isFiltered = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return isFiltered ? ValueSetValidationResult.Filtered : ValueSetValidationResult.Valid;
|
||||
var filteredValueSet = new ValueSet(valueSet.Id, valueSet.Category, valueSet.ItemType, filteredValues.ToDictionary(x => x.Key, x => (IEnumerable<object>)x.Value));
|
||||
return new ValueSetValidationResult(isFiltered ? ValueSetValidationStatus.Filtered : ValueSetValidationStatus.Valid, filteredValueSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
|
||||
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" /> <!-- Explicit updated this nested dependency due to this https://github.com/dotnet/announcements/issues/178-->
|
||||
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
|
||||
<PackageReference Include="Examine.Core" Version="2.0.1" />
|
||||
<PackageReference Include="Examine.Core" Version="3.0.0-beta.9" />
|
||||
<PackageReference Include="Umbraco.Code" Version="2.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
Reference in New Issue
Block a user