Sorting on property with JsonProperty with PropertyName set

Vote:
 

I have the following product content:

public class SampleProduct : ProductContent
{
    [JsonProperty(PropertyName = "heading")]
    public override string DisplayName { get => base.DisplayName; set => base.DisplayName = value; }
}

When its indexed I can see that the field in the index is name: heading$$string. And when trying to sort on this property with:

var searchResult = _client.Search<SampleProduct>()
    .PublishedInCurrentLanguage();
    .Order(p => p.DisplayName)
    .GetContentResult();

The documents does not get sorted correctly. If I remove the JsonProperty-attribute and re-index all content it works correctly.

#199429
Edited, Nov 27, 2018 18:05
Vote:
 

Hi,

My question would be: why are you setting a JSON property name?

If you're using the SampleProduct in your own API or view then I'd suggest mapping it into something relevant for the presentation layer - a view/API model object.

/Jake

#199571
Edited, Nov 30, 2018 20:16
* 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.