Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Property 'PageName' does not exist, can only assign values to existing properties

Vote:
 

Hi all,

I have installed EPiServer Find version 1.0.0.343 to an CMS 6 R2 site. Indexing, browsing the index etc are working as it should, but when I try to do a search trough the API it fails. Have I missed something basic?

Code:

IClient client = EPiServer.Find.Client.CreateFromConfig();
var searchQuery = Request.QueryString[QueryParameters.SearchParameterName];
            
IQueriedSearch<PageData, QueryStringQuery> queriedSearch = client.Search<PageData>().For(searchQuery);
SearchResults<PageData> searchResults = queriedSearch.GetResult();

Gives error:

Line 28:             
Line 29:             IQueriedSearch<PageData, QueryStringQuery> queriedSearch = client.Search<PageData>().For(searchQuery);
Line 30:             SearchResults<PageData> searchResults = queriedSearch.GetResult();
Line 31: 
Line 32:             if( category != null)


Source File: c:\EPiServer\Sites\Customer\src\Project\Templates\Pages\Search.aspx.cs    Line: 30 

Stack Trace: 

[EPiServerException: Property 'PageName' does not exist, can only assign values to existing properties]
   EPiServer.Core.PageData.SetValue(String index, Object value) +182
   EPiServer.Core.PageData.set_Item(String index, Object value) +40
   EPiServer.Core.PageData.set_PageName(String value) +43
   SetPageName(Object , Object ) +131
   Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value) +158

[JsonSerializationException: Error setting value to 'PageName' on 'EPiServer.Core.PageData'.]
   Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value) +283
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) +694
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) +1931
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +524
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +189
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) +739
   Newtonsoft.Json.Serialization.JsonSerializerProxy.DeserializeInternal(JsonReader reader, Type objectType) +81
   Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) +47
   EPiServer.Find.Api.SearchHitConverter.PopulateItemProperty(JsonReader reader, JsonSerializer serializer, Type objectType, Object item) +194
   EPiServer.Find.Api.SearchHitConverter.PopulateProperty(JsonReader reader, JsonSerializer serializer, Type objectType, String propertyName, Object item) +92
   EPiServer.Find.Json.IgnoredPropertiesHandlingConverterBase.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) +625
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) +292
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) +1355
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) +858
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +238
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) +597
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) +1931
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +524
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +189
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) +597
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) +1931
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +524
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +189
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) +739
   Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) +1663
   Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) +47
   Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader) +128
   EPiServer.Find.Api.Command.GetResponse(IJsonRequest request) +270
   EPiServer.Find.Api.SearchCommand`1.Execute() +720
   EPiServer.Find.Client.Search(SearchRequestBody requestBody, Action`1 commandAction) +306
   EPiServer.Find.SearchExtensions.GetResult(ISearch`1 search) +349
   Customer.Web.Templates.Pages.Search.OnInit(EventArgs e) in c:\...\Search.aspx.cs:30
   System.Web.UI.Control.InitRecursive(Control namingContainer) +134
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +489

I can see in Fiddler that the result from es-api01.episerver.com has a value for PageName$$string=Tittel på side

What am I missing here?

#85490
Apr 28, 2014 12:18
Vote:
 

Can you tried GetContentResult instead?
It will return PageData (or rahter IContent-data) to you.

#85491
Apr 28, 2014 12:45
Vote:
 

try using SearchClient.Instance instead of CreateFromConfig, and use GetPagesResult instead of GetResult.

 

 

#85618
Apr 30, 2014 14:40
Vote:
 

GetPagesResult() doesnt exist in epifind 1.0.0.343 (using epi 6r2). Allthough the wiki says it should.. 

http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Find/8/Integration/EPiServer-CMS-6-R2/Querying-examples-CMS-6-R2/

Anyone with similiar problem?

#90255
Sep 04, 2014 13:38
Vote:
 
Are you 
using EPiServer.Find;
using EPiServer.Find.Cms;
?
#90257
Sep 04, 2014 13:57
Vote:
 

Yes using statement for episerver.find.cms solved it thx :) Intelisence and EpiFind are not best palls :)

#90259
Sep 04, 2014 14:01
Vote:
 

What if I want to find content that is NOT of type IContentData? GetResult() crashes with the above-mentioned error, while GetContentResult(), which does not crash, can only be used for IContentData. Any solutions? This seems like a rather important bug, as it severely limits the ways we can use the Find index.

#90849
Sep 19, 2014 9:18
Vote:
 

What model and query are you trying with?

#90851
Sep 19, 2014 9:22
Vote:
 

Model? Query? I'm actually not sure what you are asking about... Latest version of EPiServer CMS + EPiServer Find.

            var result = _client.Search()
                .GetResult();

As long as I was only searching my index for page types, the above-mentioned work-around of using GetContentResult() workied fine.

#90852
Edited, Sep 19, 2014 9:25
Vote:
 

Model as in "show us the class code for MySpecialObjectThatIsNotAndShouldNotBeOfTypeIContentData" :)

#90853
Sep 19, 2014 9:30
Vote:
 

The class I'm indexing here:

    public class CourseWithMetaData
    {
        [Id]
        public Guid CourseGuid { get; set; }
        public CoursePage CoursePage { get; set; }
        public CourseContainer MetaData { get; set; }
        public string SearchTitle { get; set; }
    }

Indexing is done with:

            ContentIndexer.Instance.Conventions.ForInstancesOf()
                .ShouldIndex(new EPiServerFindIndexing().CoursePageIndexingWithMetaData);

Which is calling this:

    public class EPiServerFindIndexing
    {
        private readonly ICourseDelegate _courseDelegate = ServiceLocator.Current.GetInstance();

        public bool CoursePageIndexingWithMetaData(CoursePage coursePage)
        {
            var metaData = GetMetaDataAsync(coursePage);
            var courseWithMetaData = new CourseWithMetaData
            {
                CourseGuid = new Guid(coursePage.KursId),
                CoursePage = coursePage,
                MetaData = metaData,
                SearchTitle = coursePage.Name
            };

            SearchClient.Instance.Index(courseWithMetaData);
            return false;
        }

        private CourseContainer GetMetaDataAsync(CoursePage coursePage)
        {
            return _courseDelegate.GetAsync(new Guid(coursePage.KursId)).Result;
        }
    }

This works fine, and everything shows up in the index as expected, with all relevant data etc.

The search code is this:

        public List GetAllCourses()
        {
            var result = _client.Search()
                .Select(x => x.CoursePage)
                .GetResult();

            return result.ToList();
        }

This crashes with the following error:

Server Error in '/' Application. Property 'PagePendingPublish' does not exist, can only assign values to existing properties Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: EPiServer.Core.EPiServerException: Property 'PagePendingPublish' does not exist, can only assign values to existing properties

Source Error:

Line 65:         public List GetAllCourses()
Line 66:         {
Line 67:             var result = _client.Search()
Line 68:                 .Select(x => x.CoursePage)
Line 69:                 .GetResult();


Source File: c:\Workspaces\Tekna.no\Source\Main\Delegate\Implementations\SearchDelegate.cs    Line: 67

Stack Trace:

[EPiServerException: Property 'PagePendingPublish' does not exist, can only assign values to existing properties]
   EPiServer.Core.ContentData.SetValue(String index, Object value) +221
   EPiServer.Core.PageData.set_IsPendingPublish(Boolean value) +66
   Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value) +410

[JsonSerializationException: Error setting value to 'IsPendingPublish' on 'CGI.Delegate.Models.Pages.CoursePage'.]
   Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value) +596
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) +454
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) +2106
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +441
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +188
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) +790
   Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) +792
   EPiServer.Find.ProjectionHelper.DeserializeObject(JToken root) +422

[ProjectionException: An exception of type JsonSerializationException was thrown while deserializing object.]
   EPiServer.Find.ProjectionHelper.DeserializeObject(JToken root) +907
   EPiServer.Find.ProjectionHelper.AddPartialFields(SearchRequestBody requestBody, SearchHit`1 searchHit, Dictionary`2 args) +1255
   EPiServer.Find.ProjectionHelper.GetFieldValues(SearchRequestBody requestBody, SearchHit`1 searchHit) +1260
   EPiServer.Find.ProjectionHelper.GetMappedSearchResultItem(SearchRequestBody requestBody, SearchHit`1 searchHit) +248
   EPiServer.Find.ProjectionHelper.GetMappedResult(SearchRequestBody requestBody, SearchResults`1 jsonResult) +642
   EPiServer.Find.SearchExtensions.GetProjectedResult(ISearch`1 search, SearchContext context) +591
   EPiServer.Find.SearchExtensions.GetResult(ISearch`1 search) +496
   CGI.Delegate.Implementations.SearchDelegate.GetAllCourses() in c:\Workspaces\Tekna.no\Source\Main\Delegate\Implementations\SearchDelegate.cs:67
   CGI.Tekna.Controllers.CourseListPageController.Index(CourseListPage currentPage) in c:\Workspaces\Tekna.no\Source\Main\Tekna\Controllers\CourseListPageController.cs:19
   lambda_method(Closure , ControllerBase , Object[] ) +127
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +242
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +12
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +139
   System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3f() +112
   System.Web.Mvc.Async.<>c__DisplayClass48.b__41() +452
   System.Web.Mvc.Async.<>c__DisplayClass48.b__41() +452
   System.Web.Mvc.Async.<>c__DisplayClass48.b__41() +452
   System.Web.Mvc.Async.<>c__DisplayClass48.b__41() +452
   System.Web.Mvc.Async.<>c__DisplayClass48.b__41() +452
   System.Web.Mvc.Async.<>c__DisplayClass48.b__41() +452
   System.Web.Mvc.Async.<>c__DisplayClass33.b__32(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2b.b__1c() +37
   System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) +241
   System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
   System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

#90863
Sep 19, 2014 13:18
Vote:
 

You need to (re)set the CoursePage property using a call to EPiServer's ContentRepository in order to get everything populated correctly, Find module can't do this on it's own (I'm fairly certain).

This is what GetContentResult() does with it's internal GetResult() call result set, it does a ContentRepository.GetContents([] id, id, id) on the found contents' references and therefore always has live data from regular cache or db.

#90865
Edited, Sep 19, 2014 13:33
Vote:
 

Superb! This works:

        public List GetAllCourses()
        {
            var result = _client.Search()
                .Select(x => _contentRepository.Get(x.CoursePage.PageLink))
                .GetResult();

            return result.ToList();
        }

Thanks a lot!

#90866
Sep 19, 2014 13:52
Vote:
 

Got the same error in 7,5.

Using GetPagesResult() instead of GetResult() solved the problem for me.

#113950
Dec 02, 2014 10:51
Vote:
 

The error still exist in EPiServer Find 12

In my case i tried to move the SearchResult construction out of the query, IE

.Select(x => new SearchResult
{
    Url = resolver.GetUrl(x.ContentLink),
    Title = string.IsNullOrEmpty(x.Title) ? x.Name : x.Title,
    Section = x.SearchSection(),
    Excerpt = x.MainBody == null
        ? ""
        : x.MainBody.AsHighlighted(new HighlightSpec
        {
            NumberOfFragments = 3,
            Concatenation = fragments => fragments.Concatenate(" ... "),
            FragmentSize = 150
        })
})

To

.Select(x => new SearchResult(x))

// where the constructor of SearchResult looks like this

public SearchResult(ArticlePage articlePage)
{
    var resolver = ServiceLocator.Current.GetInstance<UrlResolver>();

    Url = resolver.GetUrl(articlePage.ContentLink);
    Title = string.IsNullOrEmpty(articlePage.Title) ? articlePage.Name : articlePage.Title;
    Section = articlePage.SearchSection();
    Excerpt = articlePage.MainBody == null
        ? ""
        : articlePage.MainBody.AsHighlighted(new HighlightSpec
        {
            NumberOfFragments = 3,
            Concatenation = fragments => fragments.Concatenate(" ... "),
            FragmentSize = 150
        });
}

Silly me to think that would work

It appears this limitation is somehow documented as well

The Select method's primary limitation is that it does not support projecting from complex types, except for enumerables of non-complex types.

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Searching/Projections/

#158304
Edited, Sep 27, 2016 10:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.