Add Sort in Liferay searchAdd Sort in Liferay searchhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1147589272024-03-29T09:43:51Z2024-03-29T09:43:51ZRE: Add Sort in Liferay searchSamuel Colinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1206847432021-03-15T18:54:09Z2021-03-15T09:14:24Z<p>Hy ,</p>
<p>Don't forget to add your sorted column on this property
(portal-ext.properties) : </p>
<pre><code class="language-java">index.sortable.text.fields=...</code></pre>
<p> </p>Samuel Colin2021-03-15T09:14:24ZRE: Add Sort in Liferay searchGohel Manojhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147685602019-08-16T05:12:41Z2019-08-16T05:12:41Z<html><head></head><body>Thanks for your help, but it is still not working.<br><br>Same as like <a href="https://portal.liferay.dev/docs/7-2/user/-/knowledge_base/u/sorting-search-results-with-the-sort-widget">7.2</a> i want to implement into 7.1, i tried many time but still not working.<br>I write one IndexerPostProcessor and below is a code snipest. <pre><code>@Override
&nbsp;&nbsp; &nbsp;public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter booleanFilter,
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SearchContext searchContext) throws Exception {</code></pre><pre><code>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;searchContext.setSorts(new Sort(Field.PUBLISH_DATE, Sort.SCORE_TYPE, false));
&nbsp;&nbsp; &nbsp;}</code></pre><span style="color: #e83e8c"><span style="font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace"><span style="font-size: 14px;"></span></span></span></body></html>Gohel Manoj2019-08-16T05:12:41ZRE: Add Sort in Liferay searchRussell Bohlhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147651852019-08-14T19:29:22Z2019-08-14T19:29:22Z<html><head></head><body>First suggestion: move to 7.2, where sorting results is a built-in capability: <a href="https://portal.liferay.dev/docs/7-2/user/-/knowledge_base/u/sorting-search-results-with-the-sort-widget">https://portal.liferay.dev/docs/7-2/user/-/knowledge_base/u/sorting-search-results-with-the-sort-widget</a><br>On 7.1, this appears to be the general pattern fo building a sort and adding it to the search context:<br><pre><code>SortFactory sortFactory = new SortFactoryImpl();
</code></pre><pre><code>Sort sort = sortFactory.create(String fieldName, int type, boolean reverse);
</code></pre><pre><code>searchContext.setSorts(sort));
</code></pre><br>If that doesn't push you toward a solution, you might have to be more specific with your question. I don't know if I can help you, but it makes it easier for a real expert to help if it's clear what you're trying to do, what you've tried, and how it failed.<br>Good luck!</body></html>Russell Bohl2019-08-14T19:29:22ZAdd Sort in Liferay searchGohel Manojhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147589262019-08-14T12:07:58Z2019-08-14T12:07:58ZHello All,<br />I want to add Sort functionality into Default Liferay search can any one suggest me how i can achieve this.?(same as like Let the User Choose scope is given into configuration).<br /><br />I already use SearchBar fragment and SearchResult fragment, In SearchBar fragment add two select bo