Merge pull request #2348 from umbraco/temp-U4-10588
U4-10588 Indexed member data is missing fields
This commit is contained in:
@@ -555,7 +555,7 @@ namespace Umbraco.Web.Editors
|
||||
var builtInAliases = Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray();
|
||||
foreach (var p in contentItem.PersistedContent.Properties)
|
||||
{
|
||||
var valueMapped = currProps.SingleOrDefault(x => x.Alias == p.Alias);
|
||||
var valueMapped = currProps.FirstOrDefault(x => x.Alias == p.Alias);
|
||||
if (builtInAliases.Contains(p.Alias) == false && valueMapped != null)
|
||||
{
|
||||
p.Value = valueMapped.Value;
|
||||
|
||||
@@ -97,17 +97,8 @@ namespace Umbraco.Web.WebApi.Binders
|
||||
if (member == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not find member with key " + key);
|
||||
}
|
||||
}
|
||||
|
||||
var standardProps = Constants.Conventions.Member.GetStandardPropertyTypeStubs();
|
||||
|
||||
//remove all membership properties, these values are set with the membership provider.
|
||||
var exclude = standardProps.Select(x => x.Value.Alias).ToArray();
|
||||
|
||||
foreach (var remove in exclude)
|
||||
{
|
||||
member.Properties.Remove(remove);
|
||||
}
|
||||
return member;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,12 @@ namespace UmbracoExamine.Config
|
||||
/// </summary>
|
||||
public static class IndexSetExtensions
|
||||
{
|
||||
internal static IIndexCriteria ToIndexCriteria(this IndexSet set, IDataService svc,
|
||||
StaticFieldCollection indexFieldPolicies)
|
||||
internal static IIndexCriteria ToIndexCriteria(this IndexSet set,
|
||||
IDataService svc,
|
||||
StaticFieldCollection indexFieldPolicies,
|
||||
IEnumerable<IndexField> additionalUserFields = null)
|
||||
{
|
||||
return new LazyIndexCriteria(set, svc, indexFieldPolicies);
|
||||
return new LazyIndexCriteria(set, svc, indexFieldPolicies, additionalUserFields);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace UmbracoExamine.Config
|
||||
public LazyIndexCriteria(
|
||||
IndexSet set,
|
||||
IDataService svc,
|
||||
StaticFieldCollection indexFieldPolicies)
|
||||
StaticFieldCollection indexFieldPolicies,
|
||||
IEnumerable<IndexField> additionalUserFields = null)
|
||||
{
|
||||
if (set == null) throw new ArgumentNullException("set");
|
||||
if (indexFieldPolicies == null) throw new ArgumentNullException("indexFieldPolicies");
|
||||
@@ -21,7 +22,7 @@ namespace UmbracoExamine.Config
|
||||
_lazyCriteria = new Lazy<IIndexCriteria>(() =>
|
||||
{
|
||||
var attributeFields = set.IndexAttributeFields.Cast<IIndexField>().ToArray();
|
||||
var userFields = set.IndexUserFields.Cast<IIndexField>().ToArray();
|
||||
var userFields = set.IndexUserFields.Cast<IIndexField>().ToList();
|
||||
var includeNodeTypes = set.IncludeNodeTypes.Cast<IIndexField>().Select(x => x.Name).ToArray();
|
||||
var excludeNodeTypes = set.ExcludeNodeTypes.Cast<IIndexField>().Select(x => x.Name).ToArray();
|
||||
var parentId = set.IndexParentId;
|
||||
@@ -44,7 +45,7 @@ namespace UmbracoExamine.Config
|
||||
}
|
||||
fields.Add(field);
|
||||
}
|
||||
userFields = fields.ToArray();
|
||||
userFields = fields.ToList();
|
||||
}
|
||||
|
||||
//if there are no attribute fields defined, we'll populate them from the data source (include them all)
|
||||
@@ -68,6 +69,19 @@ namespace UmbracoExamine.Config
|
||||
attributeFields = fields.ToArray();
|
||||
}
|
||||
|
||||
//merge in the additional user fields if any are defined
|
||||
if (additionalUserFields != null)
|
||||
{
|
||||
foreach (var field in additionalUserFields)
|
||||
{
|
||||
var f = field; //copy local
|
||||
if (userFields.Any(x => x.Name == f.Name) == false)
|
||||
{
|
||||
userFields.Add(f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new IndexCriteria(
|
||||
attributeFields,
|
||||
|
||||
@@ -115,34 +115,26 @@ namespace UmbracoExamine
|
||||
/// <returns></returns>
|
||||
protected override IIndexCriteria GetIndexerData(IndexSet indexSet)
|
||||
{
|
||||
var indexerData = base.GetIndexerData(indexSet);
|
||||
|
||||
if (CanInitialize())
|
||||
{
|
||||
//If the fields are missing a custom _searchEmail, then add it
|
||||
|
||||
if (indexerData.UserFields.Any(x => x.Name == "_searchEmail") == false)
|
||||
//Add a custom _searchEmail to the index criteria no matter what is in config
|
||||
var field = new IndexField { Name = "_searchEmail" };
|
||||
StaticField policy;
|
||||
if (IndexFieldPolicies.TryGetValue("_searchEmail", out policy))
|
||||
{
|
||||
var field = new IndexField { Name = "_searchEmail" };
|
||||
|
||||
StaticField policy;
|
||||
if (IndexFieldPolicies.TryGetValue("_searchEmail", out policy))
|
||||
{
|
||||
field.Type = policy.Type;
|
||||
field.EnableSorting = policy.EnableSorting;
|
||||
}
|
||||
|
||||
return new IndexCriteria(
|
||||
indexerData.StandardFields,
|
||||
indexerData.UserFields.Concat(new[] { field }),
|
||||
indexerData.IncludeNodeTypes,
|
||||
indexerData.ExcludeNodeTypes,
|
||||
indexerData.ParentNodeId
|
||||
);
|
||||
field.Type = policy.Type;
|
||||
field.EnableSorting = policy.EnableSorting;
|
||||
}
|
||||
}
|
||||
|
||||
return indexerData;
|
||||
return indexSet.ToIndexCriteria(DataService, IndexFieldPolicies,
|
||||
//add additional explicit fields
|
||||
new []{field});
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.GetIndexerData(indexSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,8 +232,8 @@ namespace UmbracoExamine
|
||||
protected override XDocument GetXDocument(string xPath, string type)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the special __key and _searchEmail fields
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user