Message Boards

sort SearchResultsPortlet results

Iñigo Boyano, modified 3 Years ago.

sort SearchResultsPortlet results

Junior Member Posts: 96 Join Date: 2/4/14 Recent Posts

Hi, 

I need to show the results of a search by createdDate.

I'm not sure how the SearchResultsPortlet is sortering the results, but it is not by createdDate. I've tried to change this sort by configuration of searchResultsPortlet or SearchOptionsPortlet by none of these portlets causes the results to be displayed by createdDate.

I've created a new Facet to do this requiriment but what I need is to directly show the results sortered and not after clicking in the facet.

How can I achieve this requirement?

Any idea?

Kind regards, 

Iñigo

thumbnail
Russell Bohl, modified 3 Years ago.

RE: sort SearchResultsPortlet results

Expert Posts: 291 Join Date: 2/13/13 Recent Posts

I didn't  see what Liferay version you're using, but on 7.2 and 7.3 you can do this with the Custom Filter widget.

See Filtering Search Results for more details, and let us know if you run into any issues.

Iñigo Boyano, modified 3 Years ago.

RE: RE: sort SearchResultsPortlet results

Junior Member Posts: 96 Join Date: 2/4/14 Recent Posts

Sorry I forgot to write the version...-

I'm using a Liferay 7.2 version with dxp-8-7210 patching level.

 

thumbnail
Russell Bohl, modified 3 Years ago.

RE: sort SearchResultsPortlet results

Expert Posts: 291 Join Date: 2/13/13 Recent Posts

Great, then you can use the Cusomt Filter widget. It's a bit hard to see but there's a hyperlink to the docs in my last post. Here it is again, less disguised:

 

https://learn.liferay.com/dxp/7.x/en/using-search/search-pages-and-widgets/search-results/filtering-search-results.html

Iñigo Boyano, modified 3 Years ago.

RE: RE: sort SearchResultsPortlet results

Junior Member Posts: 96 Join Date: 2/4/14 Recent Posts

Thanks for your quick response.

I'm trying to make the filter by createDate, but I can't achieve yet, any suggestion?

When I use the sort Portlet, the URL result is something like ...&sort=createDate%2B, I need to create something like that using the custom Filter i guess

thumbnail
Russell Bohl, modified 3 Years ago.

RE: sort SearchResultsPortlet results

Expert Posts: 291 Join Date: 2/13/13 Recent Posts

Ahh shoot, you are trying to sort not filter. I shou;dn't have replied before having any coffee :(

 

So sorry to send you down the wrong path, let me look into it a bit more.

thumbnail
Russell Bohl, modified 3 Years ago.

RE: sort SearchResultsPortlet results

Expert Posts: 291 Join Date: 2/13/13 Recent Posts

When I use the sort Portlet, the URL result is something like ...&sort=createDate%2B, I need to create something like that using the custom Filter i guess

Is there a reason you're not using the Sort Portlet?

Iñigo Boyano, modified 3 Years ago.

RE: RE: sort SearchResultsPortlet results

Junior Member Posts: 96 Join Date: 2/4/14 Recent Posts

The Sort Portlet works properly when I select the create option in the select but, what i need, its to show the results sorted by created Date when the page is loaded, in the first view without clicking anything.

The results have to be showed by createDate- by default

thumbnail
Russell Bohl, modified 3 Years ago.

RE: sort SearchResultsPortlet results

Expert Posts: 291 Join Date: 2/13/13 Recent Posts

Yeah, I see what you mean. I expected that if we put the created option at the top of the sort configuration, it would be applied on page load. But it's not. I'm going to check two things:

 

  1. Is it expected that the first option in the sort widget should be applied by default?
  2. Is there another way to enforce the default sort order in the results widget?
thumbnail
Russell Bohl, modified 3 Years ago.

RE: sort SearchResultsPortlet results

Expert Posts: 291 Join Date: 2/13/13 Recent Posts

I've asked these questions internally, and so far, we think you've hit a bug in the sort portlet. The first option configured in the Sort Portlet (Relevance OOTB) should probably be applied on page load, so switching the order to use created as the first option should be all you need to do. However, as you and I have both observed, it's not working as expected.

I've filed a ticket here: https://issues.liferay.com/browse/LPS-123103

Iñigo Boyano, modified 3 Years ago.

RE: RE: sort SearchResultsPortlet results

Junior Member Posts: 96 Join Date: 2/4/14 Recent Posts

Thanks to create the ticket.

I'll be waiting for the answer of the ticket before of develop other diferent solutions.

Kind regards