Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Archi Madhu
How to sort search results in liferay search portlet by title?
February 1, 2010 8:02 PM
Answer

Archi Madhu

Rank: Regular Member

Posts: 240

Join Date: March 24, 2008

Recent Posts

Hi All,

I need to sort search results by "title" in default search portlet provided by Liferay.

I see that in default search container there is no header "title" in it,instead they have header called summary in which they are adding title and description of article.

So how to sort results by title?

Even I tried to set a header "title" and appended results in string buffer.

I tried to set

SearchContainer.setOrderByCol("title");
SearchContainer.getOrderByType("asc");

But,When I tried to print them it gives null!

Can anyone suggest me how to sort search results by content title?

Thanks a lot
Archi
Sandeep Atmakuri
RE: How to sort search results in liferay search portlet by title?
February 25, 2011 2:20 PM
Answer

Sandeep Atmakuri

Rank: New Member

Posts: 24

Join Date: February 12, 2011

Recent Posts

Hi,

I'm new to Liferay and I'm trying to sort the results by Title as you specified in the post.

Were you able to figure out how to implement that?

Thanks

Sandeep
M. Garcia
RE: How to sort search results in liferay search portlet by title?
June 20, 2011 2:09 AM
Answer

M. Garcia

Rank: Regular Member

Posts: 107

Join Date: May 17, 2011

Recent Posts

I'm trying the same thing, ordering a List of articles by title.

Liferay provides the OrderByComparator class, which has a lot of subclasses such as ArticleTitleComparator.
It can be used in the JournalArticleLocalServiceUtil functions to retrieve articles, such as getArticles(String groupId, int begin, int end, OrderByComparator obc).

So from what i understand, if you do :
1List<JournalArticle> jaList =
2        JournalArticleLocalServiceUtil.getStructureArticles(
3                GROUP_ID, STRUCTURE_ID, 0, 9999, new ArticleTitleComparator() );


your list should contain all articles from a group Id, with the specified structure, and should be sorted by article title.

In my case I do get the list of articles of the specified structure, but they're not ordered at all...

Am I misunderstanding the use of ArticleTitleComparator ?
M. Garcia
RE: How to sort search results in liferay search portlet by title?
June 27, 2011 7:31 AM
Answer

M. Garcia

Rank: Regular Member

Posts: 107

Join Date: May 17, 2011

Recent Posts

Anyone has an idea on this ? I still couldn't manage to sort the JournalArticle List.

I also tried :
1Collections.sort(jaList, new ArticleTitleComparator());


But without success... seems like ArticleTitleComparator does not work.
Amadou korka DIALLO
RE: How to sort search results in liferay search portlet by title?
February 5, 2012 11:33 AM
Answer

Amadou korka DIALLO

Rank: New Member

Posts: 2

Join Date: November 11, 2011

Recent Posts

Bonjour,

Avez vous une solution, je suis confronté au même problème.

Merci.
Vipin Bardia
RE: How to sort search results in liferay search portlet by title?
February 5, 2012 10:33 PM
Answer

Vipin Bardia

Rank: Regular Member

Posts: 113

Join Date: February 27, 2011

Recent Posts

Hi,

Try this Link
http://vkbardia.blogspot.in/2012/01/column-base-sorting-in-search-container.html

Regards,
Vipin Bardia
python shi
RE: How to sort search results in liferay search portlet by title?
August 13, 2014 8:10 PM
Answer

python shi

Rank: New Member

Posts: 11

Join Date: July 2, 2012

Recent Posts

Hi, Archi Madhu,

Have you already solved the problem, I have the same one!

When search documents in Document and Media portlet, it display the results which is my expectant.

Then, I click the "title" header, sort the search results by title, but it direct to the Document and Media portlet "/home" directory.

Any suggestion can help me?
Sai Sriharsha Kasturi
RE: How to sort search results in liferay search portlet by title?
December 24, 2014 2:43 AM
Answer

Sai Sriharsha Kasturi

Rank: New Member

Posts: 11

Join Date: October 21, 2012

Recent Posts

If you're hooking the search portlet, then place the following code in "main_search.jspf"

Sort[] sorts = new Sort[] {new Sort(Field.TITLE, true)};
searchContext.setSorts(sorts);