Try our conversational search powered by Generative AI!

Epi Search - Specify order

Vote:
 

Hi, 

I’m using EPi Search to find x number of newspages and display these in a list. To get the next x number of news the visitor hits a ”Show more” button.

The search works fine, but the problem is that it returns the oldest pages first. I want the latest created pages to be returned first. 

I can't sort the pages after the search is performed since we are not searching for all newspages at a time.

Is it possible to specifiy an order when using EPi Search?

 

Thanks for your help

/Malin

#178002
Apr 26, 2017 15:00
Vote:
 

How about something like this?

FilterForVisitor.Filter(_newsPageItems);
new FilterSort(FilterSortOrder.CreatedDescending).Filter(_newsPageItems);


#178014
Apr 26, 2017 21:00
Vote:
 

Can you post the code snippet you are using? 

#178015
Apr 26, 2017 21:02
Vote:
 

Hi,

I think the FilterForVisitor is wrong, because I think Malin wants to set the sortorder when doing the search, not after. 

For example if it was Find, she could do this: 

client.Search<NewsPage>()
    .OrderBy(x => x.PublicationDate)
.GetResult();


I think it's something like that she wants to do in Search

/ Henric

#178019
Apr 27, 2017 8:44
Vote:
 

Thanks for your reply. Henric is right, I need to sort while searching. 

This is how we are performing the search

var Locate = ServiceLocator.Current.GetInstance<ServiceLocationHelper>();

GroupQuery groupQuery = new GroupQuery(LuceneOperator.AND);

var contentTypesQuery = new GroupQuery(LuceneOperator.OR);

//Here we are specifying what type to search for, ex searchOnType = newspages

contentTypesQuery.QueryExpressions.Add(new TypeContentQuery(searchOnType));

groupQuery.QueryExpressions.Add(contentTypesQuery);

VirtualPathQuery pathQuery = new VirtualPathQuery();

pathQuery.AddContentNodes(searchRoot, Locate.ContentLoader());

groupQuery.QueryExpressions.Add(pathQuery);

AccessControlListQuery aclQuery = new AccessControlListQuery();

aclQuery.AddAclForUser(PrincipalInfo.Current, httpContext);

groupQuery.QueryExpressions.Add(aclQuery);

//Here is were I perform the search and only take x number of items (value of pagingNumber * pagingSize). 

var results = Locate.SearchHandler().GetSearchResults(groupQuery, pagingNumber, pagingSize);

#178031
Apr 27, 2017 11:11
Vote:
 

The search returns the pages in the order they were indexed.

So the most recently updated pages, which have been indexed last, is returned last. 

I would like to do quite the opposite, but without having to get all search hits first.  

#178032
Apr 27, 2017 11:18
* 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.