Try our conversational search powered by Generative AI!

Sorting Issue when sorting by date

Vote:
 

We are experiencing alot of issues with with orderby in our results.  Especially happening with Dates and strings.  The order by on a property Title for example puts abdominal at the end of the list and shows adolecent as the first item.  Clearly not working.  Another instance is the date.

Here is the result of 7 events sorted by date

7/26/2018 6:15:00 PM
9/10/2018 9:00:00 AM
10/27/2018 8:30:00 AM
7/28/2018 9:00:00 AM
11/2/2018 7:30:00 AM
11/29/2018 8:00:00 AM
7/22/2018 9:00:00 AM
Here is the code.
            var query = this.searchClient.Search();

            if (q.HasValue())
                query = query.For(q);

            if (currentPage.EventTypes.HasValue())
            {
                var eventTypeFilter = this.searchClient.BuildFilter();
                foreach (var eventType in currentPage.EventTypes.Select(x => x.ToReferenceWithoutVersion().ID))
                    eventTypeFilter = eventTypeFilter.Or(x => x.EventTypeIdList.Match(eventType));

                query = query.Filter(eventTypeFilter);
            }

            if (currentPage.ScopeOverride.HasValue())
                query = query.Filter(x => x.Ancestors().Match(currentPage.ScopeOverride.ToReferenceWithoutVersion().ID.ToString()));

            query = query
                .FilterForVisitor()
                .ExcludeDeleted()
                .Filter(x => x.EndDateTime.GreaterThan(DateTime.Now))
                .OrderBy(x => x.StartDateTime)
                .Skip(model.PageWeight * p)
                .Take(model.PageWeight);

            var results = query.GetContentResult();

We are using version 13.0.1.0

#195268
Jul 19, 2018 5:36
Vote:
 

Hi Joshua,

Your issue looks familiar :) This is known issue FIND-3596 and will be fixed in next versions.

For your case, the working around for OrderBy clause will be 

.OrderBy(x => x.StartDateTime, null, SortOrder.Descending, false)

- make sure that IgnoreUnmapped params is false.

Hope this help.

/Son Do

#195373
Edited, Jul 22, 2018 5:31
* 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.