EPiFind Nested Sorting Bad Request

Vote:
 

Hi,

I am trying to sort some objects by a nesten field, but cannot seem to get it working. I would like to sort all the results, (each containing the EnumerableField) based on the first element matching the z-lambda function of all the elements.

This is the nested sorting function I am using, which produces a "EPiServer.Find.ServiceException: 'The remote server returned an error: (400) Bad Request".

:

search.OrderBy(x => x.EnumerableField,
         y => y.DecimalNumber,
         z => z.ValidTo.After(DateTime.Now) & z.IsActive.Match(true) & z.ValidFrom.Before(DateTime.Now));

I have also tested sorting with .FirstOrDefault(...) but to no avail. As opposed to the previous approach, this one does not seem to do anything:

search.OrderBy(x => x.EnumerableField.FirstOrDefault(z => z.ValidTo > DateTime.Now & z.IsActive & z.ValidFrom < DateTime.Now).DecimalNumber);

Is there something I am missing, or is this not possible?

The find-index objects is grouped in this way:

{
    "MetaClassId$$number": ..,
    "GetTimestamp$$date": ..,
    ...,
    "EnumerableField": [
        {
            "___types": [
                "...",
                "System.Object"
            ],
            "DecimalNumber$$number": 0.9,
            "ValidFrom$$date": "2019-01-02T23:00:00Z",
            "ValidTo$$date": "2019-10-17T22:00:00Z",
            "Title$$string": "...",
            "ID$$number": 1,
            "$type": "....Core",
            "IsActive$$bool": true
        },
        {
            "___types": [
                "...",
                "System.Object"
            ],
            "DecimalNumber$$number": 0.2,
            "ValidFrom$$date": "2019-01-02T23:00:00Z",
            "ValidTo$$date": "2019-10-17T22:00:00Z",
            "Title$$string": "...",
            "ID$$number": 1,
            "$type": "....Core",
            "IsActive$$bool": true
        },
    ],
    ...
    "IsPendingPublish$$bool": false,
}
#201108
Edited, Feb 06, 2019 8:08
Vote:
 

I found the solution to this, it was due to not declaring the EnumerableField as a nested field.

SearchClient.Instance.Conventions.NestedConventions.ForInstancesOf<EntryContentBase>().Add(x => x.EnumerableField);
#201111
Feb 06, 2019 9:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.