Sorting issue in Episerver Find 13.0.1
We have known an issue about sorting in Find 13.0.1 that we can reproduce
- Create a developer index in find.episerver.com.
- Create some properties for string, DateTime, int type for a page type
- Create some page using those page types.
- Run the site and index the content.
- In the test page, create query and sort by Date or SortNumber.
var query = _searchClient.Search<BasePage>()
.FilterForVisitor()
.OrderBy(x => x.MyOwnDate)
.Select(x => new SearchItem
{
PageTitle = x.Name,
MyOwnDate = x.MyOwnDate,
SortNumber = x.SortNumber,
TeaserText = x.TeaserText,
ID = x.ContentLink.ID
})
.Take(100);
model.SearchResults = query.GetResult().Hits.Select(x => x.Document).ToList();
And the bug is published https://world.episerver.com/support/Bug-list/bug/FIND-3596 and will be fixed in next version.
While waiting for upgrading to the next version, we can have a way of working around:
.OrderBy(x => x.MyOwnDate, null, null, false);
// Or
.OrderBy(x => x.MyOwnDate, null, SortOrder.Ascending, false);
// For order descending, we had:
.OrderBy(x => x.MyOwnDate, null, SortOrder.Descending, false);
We need to change OrderBy clause and make sure that the ignoreUnmapped parameter is false.
We can apply the same working around for other types: date, int, ...
Hope this helps your work.
/Son Do
Great, thanks! I received several questions from partner yesterday. Not sure if we have official location to create a bug or request from user. She created a thread on World only.
Hi Khanh, World forum is a place that we can discuss and post bug. Currently, we don't have another channel for developers do that.
Thank @Khanh for helping with this question!
Hi @SonDo, I tried following your instruction but it still does not work.
I have the ArticlePage with [ArticleDate] which is my custom field. Trying to make the very simple search query with the sorting(tried both Assending and Dessending) but the result was not sorted.
Please see the attached image for more detail(https://ibb.co/ePKHL9).
The field definition:
public virtual DateTime ArticleDate { get; set; }
And the search query with the sorting:
var articles1 = _searchClient.Search(Language.English)(searchFilter)
.CurrentlyPublished()
.PublishedInCurrentLanguage()
.Filter
.ExcludeDeleted()
.OrderBy(a => a.ArticleDate, null, SortOrder.Ascending, false)
.Take(pageSize)
.StaticallyCacheFor(TimeSpan.FromMinutes(5))
.GetContentResult();
var dates = articles1.Select(x => x.ArticleDate);
Do you have any suggestion for it?
Thanks so much :).
Hi Ngoan,
Sorry for the late comment. I tried your search query in my Alloy site and it worked properly.
I'm not sure what happens to your site or your search query. Have you got more information that I can trace the issue?
/Son Do
Hi Ngoan,
Sorry for the late comment. I tried your search query in my Alloy site and it worked properly.
I'm not sure what happens to your site or your search query. Have you got more information that I can trace the issue?
/Son Do
Hey thanks for this! One thing I noticed after upgrading to 13.0.3 I was still seeing this issue. However it was bizzare because I would not see this behavior on my local solution with a find development index but this issue came to light on the development environment with the clients purchased development find license. I have since added this fix and all works as it should now, but it may be worth investigating on 13.0.3 as well.
Hi,
I am seeing the exact same behavior that Sean mentioned. On all 13.0.x versions of Find (including 13.0.3 where the issue was supposedly fixed), I only see this sorting bug on indices which are provisioned as part of a customer's DxC license (https://es-us-api01.episerver.com). I do not see this behavior with indices created on find.episerver.com (https://es-eu-dev-api01.episerver.net).
That being said, this workaround seems to work on all 13.0.x versions of Find for indices which are provided by DxC. Thank you for the valuable info!
Hi
We still having the same problem with Find 13.0.5.0 after getting a new find index on https://es-eu-api03.episerver.net
I dont get the same behovior on https://es-eu-dev-api01.episerver.net locally.
I hade to use the same workaround to make it work.
I have the same issue when sorting on nested objects with Find 13.0.5 on DXC environment. Working on demo index. The result seem to be sorted but in different fragments.
Hi @SonDo
We are having the same sorting issue with production indexes located on https://es-eu-api03.episerver.net.
Using a dev index on https://es-eu-dev-api01.episerver.net with the same content and Nuget package version (13.0.1) seems to work absolutely fine.
Is this a an index-side code issue rather than related to the client-side library?
The bug report linked to from this post doesn't have a fix version associated with it, so has it been fixed or not? - https://world.episerver.com/support/Bug-list/bug/FIND-3596
Dave