Hi!
Whenever working with EPiServer data, use SearchClient.Instance instead of Client.CreateFromConfig. SearchClient.Instance contains the neccesary conventions used for handling IContent.
However, I would recommend indexing the page reference instead of the page itself. Doing a Get(..) later on to fetch the actual page is not a costly operation. This is actually done in the standard .GetContentResult() method.
I recommend that you check this out:
http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Find1/75/Integration/EPiServer-75-CMS/GetContentResult-and-GetFilesResult/
If you need to filter on null values, you can use .Exists() to do that.
Also, if this is a large number of people, consider indexing your results in bulks:
http://world.episerver.com/Blogs/Per-Magne-Skuseth/Dates/2013/5/EPiServer-Find-Bulks-please/
I have a database of employees and many of the employees in the database have corresponding pages in EPiServer. I want to add the PageData to the model of the employee object (called PersonWrapper) being indexed to be able to access the page directly in the result without having to do a lookup for the pagedata object for each search result.
The problem I'm having is that for some properties I was unable to convert them to string. This was however solved by adding a JsonIgnoreAttribute to the properties in the PageTypeBuilder class.
But now I get the following error instead:
Self referencing loop detected for property 'Parent' with type 'EPiServer.Core.PropertyDataCollection'. Path 'PersonPage.Property[0]'. The loop was detected in the member Parent in type EPiServer.Core.PropertyCategory. To correct this you can exclude one of the properties (or otherwise mapped fields) that are causing the loop by modifying the Client class' conventions. You may also modify the serializer to ignore self references. If you require the fields causing the loop to be serialized you may annotate the one of the classes in the loop with [JsonObject(IsReference = true)] or modify the JsonContract for one of the types to use IsReference = true which also can be done by modifying the Client class' conventions.
How can I exclude the CategoryProperty from the PageData object when indexing it and why doesn't the built-in scheduler have the same problem when indexing pages? Can Conventions.ForInstancesOf<PersonWrapper>().ExcludeField(x => x.PersonPage.Category) be used and if so, how?
Another off-topic question: How can I fetch a result from EPiServer find which only gives me object where a certain property is not null?
I'd like to do something like this: Client.CreateFromConfig().Search<PersonWrapper>().Filter(x => x.PersonPage.IsNotNull()).GetResult() but that doesn't work since IsNotNull don't return a querying filter
Here is my indexing code: