Fixes: U4-4798 When new property types are added, the internal Examine index isn't notified and will ignore them
This commit is contained in:
@@ -14,58 +14,63 @@ namespace UmbracoExamine.Config
|
||||
/// </summary>
|
||||
public static class IndexSetExtensions
|
||||
{
|
||||
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
internal static IIndexCriteria ToIndexCriteria(this IndexSet set, IDataService svc,
|
||||
IEnumerable<StaticField> indexFieldPolicies)
|
||||
{
|
||||
|
||||
var attributeFields = set.IndexAttributeFields.Cast<IIndexField>().ToArray();
|
||||
var userFields = set.IndexUserFields.Cast<IIndexField>().ToArray();
|
||||
var includeNodeTypes = set.IncludeNodeTypes.ToList().Select(x => x.Name).ToArray();
|
||||
var excludeNodeTypes = set.ExcludeNodeTypes.ToList().Select(x => x.Name).ToArray();
|
||||
var parentId = set.IndexParentId;
|
||||
|
||||
//if there are no user fields defined, we'll populate them from the data source (include them all)
|
||||
if (set.IndexUserFields.Count == 0)
|
||||
{
|
||||
lock (Locker)
|
||||
//we need to add all user fields to the collection if it is empty (this is the default if none are specified)
|
||||
var userProps = svc.ContentService.GetAllUserPropertyNames();
|
||||
var fields = new List<IIndexField>();
|
||||
foreach (var u in userProps)
|
||||
{
|
||||
//we need to add all user fields to the collection if it is empty (this is the default if none are specified)
|
||||
var userFields = svc.ContentService.GetAllUserPropertyNames();
|
||||
foreach (var u in userFields)
|
||||
var field = new IndexField() { Name = u };
|
||||
var policy = indexFieldPolicies.FirstOrDefault(x => x.Name == u);
|
||||
if (policy != null)
|
||||
{
|
||||
var field = new IndexField() {Name = u};
|
||||
var policy = indexFieldPolicies.FirstOrDefault(x => x.Name == u);
|
||||
if (policy != null)
|
||||
{
|
||||
field.Type = policy.Type;
|
||||
field.EnableSorting = policy.EnableSorting;
|
||||
}
|
||||
set.IndexUserFields.Add(field);
|
||||
field.Type = policy.Type;
|
||||
field.EnableSorting = policy.EnableSorting;
|
||||
}
|
||||
fields.Add(field);
|
||||
}
|
||||
userFields = fields.ToArray();
|
||||
}
|
||||
|
||||
//if there are no attribute fields defined, we'll populate them from the data source (include them all)
|
||||
if (set.IndexAttributeFields.Count == 0)
|
||||
{
|
||||
lock (Locker)
|
||||
//we need to add all system fields to the collection if it is empty (this is the default if none are specified)
|
||||
var sysProps = svc.ContentService.GetAllSystemPropertyNames();
|
||||
var fields = new List<IIndexField>();
|
||||
foreach (var s in sysProps)
|
||||
{
|
||||
//we need to add all system fields to the collection if it is empty (this is the default if none are specified)
|
||||
var sysFields = svc.ContentService.GetAllSystemPropertyNames();
|
||||
foreach (var s in sysFields)
|
||||
var field = new IndexField() { Name = s };
|
||||
var policy = indexFieldPolicies.FirstOrDefault(x => x.Name == s);
|
||||
if (policy != null)
|
||||
{
|
||||
var field = new IndexField() { Name = s };
|
||||
var policy = indexFieldPolicies.FirstOrDefault(x => x.Name == s);
|
||||
if (policy != null)
|
||||
{
|
||||
field.Type = policy.Type;
|
||||
field.EnableSorting = policy.EnableSorting;
|
||||
}
|
||||
set.IndexAttributeFields.Add(field);
|
||||
field.Type = policy.Type;
|
||||
field.EnableSorting = policy.EnableSorting;
|
||||
}
|
||||
fields.Add(field);
|
||||
}
|
||||
attributeFields = fields.ToArray();
|
||||
}
|
||||
|
||||
|
||||
return new IndexCriteria(
|
||||
set.IndexAttributeFields.Cast<IIndexField>().ToArray(),
|
||||
set.IndexUserFields.Cast<IIndexField>().ToArray(),
|
||||
set.IncludeNodeTypes.ToList().Select(x => x.Name).ToArray(),
|
||||
set.ExcludeNodeTypes.ToList().Select(x => x.Name).ToArray(),
|
||||
set.IndexParentId);
|
||||
attributeFields,
|
||||
userFields,
|
||||
includeNodeTypes,
|
||||
excludeNodeTypes,
|
||||
parentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user