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

Try our conversational search powered by Generative AI!

Episerver Search Service Sort Order

Vote:
 

Hi,

We are currenlty working on using the default Episerver Search and we have a problem with sorting the search results.

We are following the documentation found here :https://world.episerver.com/documentation/developer-guides/CMS/search/Search-integration/

However there is no mention of a SortQuery option. 

Does anyone know if this is possible?

We would like to order the results by PublishedStartDate if possible.

Thanks

Paul

#202783
Apr 01, 2019 11:50
Vote:
 

Hi Paul,

I might have misunderstood what you are after but as the result yielded is an IEnumerable you could use Linq and OrderBy(x => x.StartPublishDate) or OrderByDescending(x => x.StartPublishDate) on the final collection.

#202793
Apr 01, 2019 16:20
Vote:
 

Hi Gustav,

In Lucence there is the ability to use a sortfield when querying for data.

Is there a way to use this in Episerver Search?

I presume we need to write our own implementation to handle this possibly?

Thanks

Paul

#202814
Apr 01, 2019 18:31
Vote:
 

If I am not wrong, you are willing to pass a sort property name in your search to get results sorted on basis of this sort property, right?

Example of function:

Sort property type

Implementation of OrderByDescending

#202828
Apr 02, 2019 9:21
Vote:
 

Search is based on lucene but I dont think that PublishedStartDate is indexed by default. Dejan Caric has written a nice blogpost about extending the index to add a new property (such as publish date) and querying for it. https://www.dcaric.com/blog/extending-episerver-search-part-2

I hope this helps!

#202831
Apr 02, 2019 9:43
Vote:
 

Thanks for the help guys.

Praful thanks for the info, though I think that solution works with Episerver Find, where we are dealing with Episerver Search.

Gustav that looks to be what we are looking for, i suppose we have to use lucence.net api rather than the Episerver Search Api's to query the index.

Thanks

Paul

#202895
Apr 03, 2019 10:27
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.