Search code examples
indexingsitecoreglass-mapper

Sitecore IndexField: resulting IEnumerable is empty


I have the following fields in my model:

public virtual IEnumerable<Person> Authors { get; set; }
public virtual IEnumerable<ExternalContributor> External_Contributors { get; set; }

[IndexField("Authors")]
[TypeConverter(typeof(IndexFieldGuidValueConverter))]
public virtual IEnumerable<Guid> AuthorIds { get; set; }

[IndexField("External Contributors")]
[TypeConverter(typeof(IndexFieldGuidValueConverter))]
public virtual IEnumerable<Guid> ExternalContributorIds { get; set; }

and I have a MultiList of GuiD in the fields "Authors" and "External Contributors". When I try to access those fields, "Authors" is populated with a list of objects, while External_Contributors is always empty.

Is there something obvious I am missing here?


EDIT: Here are the definitions for Person and ExternalContributor:

[SitecoreType(TemplateId = "{2CD821FC-A334-49F4-93B9-CB0D8E7D71FF}", AutoMap = true)]
    public class Person : ImageTemplate, ITagged, IViewImage, IViewCover, ISectors, ISpecialisms, IEquatable<Person>
    {
        public static string ParentPath = "/sitecore/content/Data/People";
        public static Guid Template = new Guid("{2CD821FC-A334-49F4-93B9-CB0D8E7D71FF}");

        [...various fields...]
    }
}

[SitecoreType(TemplateId = "{7C35993C-140B-43FE-A00A-7ADA00A2A488}", AutoMap = true)]
    public class ExternalContributor : ImageTemplate, ITagged, IViewImage, IEquatable<ExternalContributor>
    {
        public static string ParentPath = "/sitecore/content/Blue Rubicon Data/external-contributors";
        public static Guid Template = new Guid("{7C35993C-140B-43FE-A00A-7ADA00A2A488}");

        [...various fields...]
    }
}

Solution

  • What about something like this: [IndexField("External_Contributors")]

    I'm not sure, but I've never seen a index field with spaces, I don't know if the fieldname translator (if it still exists) would fix it.

    You should re-index your items after applying your change before it may work.