<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Grouping of search Results by Asset Type in Liferay DXP?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112156944" />
  <subtitle>Grouping of search Results by Asset Type in Liferay DXP?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112156944</id>
  <updated>2026-05-14T04:57:19Z</updated>
  <dc:date>2026-05-14T04:57:19Z</dc:date>
  <entry>
    <title>RE: Grouping of search Results by Asset Type in Liferay DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118096769" />
    <author>
      <name>Gopal Prasad Satapathy</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118096769</id>
    <updated>2019-12-17T08:47:41Z</updated>
    <published>2019-12-17T08:47:41Z</published>
    <summary type="html">Hello &lt;strong&gt;Gaurav,&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;My  intention is to sort the search result 1st based on the site and then based on  asset type. Is there any working example code that you can share for reference?&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Gopal</summary>
    <dc:creator>Gopal Prasad Satapathy</dc:creator>
    <dc:date>2019-12-17T08:47:41Z</dc:date>
  </entry>
  <entry>
    <title>RE: Grouping of search Results by Asset Type in Liferay DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118022992" />
    <author>
      <name>Gaurav Jain</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118022992</id>
    <updated>2019-12-09T07:45:29Z</updated>
    <published>2019-12-09T07:45:29Z</published>
    <summary type="html">Hi Narsingh Pal,&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;For your requirement, you can also try&lt;strong&gt; Boosting, &lt;/strong&gt;please have a look at following example:&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;blockquote&gt;String className = PortalUtil.getClassName(classNameId);&lt;br /&gt; BooleanQuery assetEntryQuery = new BooleanQueryImpl();&lt;br /&gt;  assetEntryQuery.addTerm(Field.ENTRY_CLASS_NAME, className);&lt;br /&gt;  float boost = 5.0;&lt;br /&gt;  assetEntryQuery.setBoost(boost);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;And use this query further......&lt;br /&gt;For each classname different boost level can be set as per the requirement, Higher boost level entities will be on higher orders.&lt;br /&gt;One more thing you need to do &lt;br /&gt;&lt;blockquote&gt;Sort[] sorts = new Sort[]{new Sort (&amp;#34;_score&amp;#34;, Sort.SCORE_TYPE, false)};&lt;br /&gt;searchContext.setSorts(sorts);&lt;br /&gt;&lt;/blockquote&gt;</summary>
    <dc:creator>Gaurav Jain</dc:creator>
    <dc:date>2019-12-09T07:45:29Z</dc:date>
  </entry>
  <entry>
    <title>RE: Grouping of search Results by Asset Type in Liferay DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118024814" />
    <author>
      <name>Narsingh Pal</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118024814</id>
    <updated>2019-12-09T05:36:36Z</updated>
    <published>2019-12-09T05:36:36Z</published>
    <summary type="html">Hi Stephan,&lt;br /&gt;&lt;br /&gt;Were you able to find solution for this ?&lt;br /&gt;&lt;br /&gt;Thanks and RegardsNarsingh Pal</summary>
    <dc:creator>Narsingh Pal</dc:creator>
    <dc:date>2019-12-09T05:36:36Z</dc:date>
  </entry>
  <entry>
    <title>RE: Grouping of search Results by Asset Type in Liferay DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112183799" />
    <author>
      <name>Stephan Neese</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112183799</id>
    <updated>2019-01-30T17:38:29Z</updated>
    <published>2019-01-30T17:38:29Z</published>
    <summary type="html">Hi Everyone,&lt;br /&gt;&lt;br /&gt;I found a pointer to a possible solution. Elastic Search for example has the so called &amp;#34;function_score&amp;#34; method. This allows you to modify the score of elements. Here is an example: &lt;br /&gt;&lt;br /&gt;&amp;#34;function_score&amp;#34; : {&lt;br /&gt;            &amp;#34;query&amp;#34;: {&lt;br /&gt;                &amp;#34;match&amp;#34;: { &amp;#34;title&amp;#34;: &amp;#34;hello world&amp;#34; }&lt;br /&gt;            },&lt;br /&gt;            &amp;#34;functions&amp;#34;: [&lt;br /&gt;                {&lt;br /&gt;                    &amp;#34;filter&amp;#34; : { &amp;#34;match&amp;#34;: { &amp;#34;entryClassName&amp;#34;: &amp;#34;com.liferay.journal.model.JournalArticle&amp;#34; } },&lt;br /&gt;                    &amp;#34;weight&amp;#34; : 10&lt;br /&gt;                },&lt;br /&gt;                {&lt;br /&gt;                    &amp;#34;filter&amp;#34; : { &amp;#34;match&amp;#34;: { &amp;#34;entryClassName&amp;#34;: &amp;#34;com.liferay.portlet.documentlibrary.model.DLFileEntry&amp;#34; } },&lt;br /&gt;                    &amp;#34;weight&amp;#34; : 5&lt;br /&gt;                }&lt;br /&gt;            ],&lt;br /&gt;            &amp;#34;boost_mode&amp;#34;: &amp;#34;sum&amp;#34;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;In this example we add 10 to the score if we have a journal article and 5 if DLFileEntry. My question now is. How do you implement this in the search. How do you need to manipulate the query in Liferay?&lt;br /&gt;&lt;br /&gt;best regards&lt;br /&gt;&lt;br /&gt;​​​​​​​Stephan</summary>
    <dc:creator>Stephan Neese</dc:creator>
    <dc:date>2019-01-30T17:38:29Z</dc:date>
  </entry>
  <entry>
    <title>Grouping of search Results by Asset Type in Liferay DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112156943" />
    <author>
      <name>Stephan Neese</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112156943</id>
    <updated>2019-01-28T15:50:54Z</updated>
    <published>2019-01-28T15:50:54Z</published>
    <summary type="html">&lt;p&gt;Hello Forum,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;a customer wants their Search Results grouped by default in the
  following way &lt;/p&gt;
&lt;p&gt;1. web contents&lt;/p&gt;
&lt;p&gt;2. documents&lt;/p&gt;
&lt;p&gt;3. everything else (order does not matter here)&lt;/p&gt;
&lt;p&gt;Since this should be sorted by default a facet wont do it here. I
  wanted to implement this using an IndexerPostProcessor and by setting
  a GroupBy Object in the SearchContext in the Processors Method
  postProcessFullQuery(). However even though the method is definitely
  called and the GroupBy Object is set in the SearchContext (I put a
  breakpoint in there) the search seems to ignore my GroupBy argument as
  the Order of the Results shown is not affected. As you can see in the
  code below I have tried to setup a very basic GroupBy Argument (I just
  added a max size of 5 to quicktest my solution). Just Telling LR by
  which Field to group. No Sort order or anything yet. Do I need to tell
  LR by which order I want to Sort the Field for it to work or activate
  the groupby somewhere? Has anyone experience with this? Thank you.&lt;/p&gt;
&lt;p&gt;Code:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt;
@Component(
   immediate = true,
   property = {
      &amp;quot;indexer.class.name=com.liferay.journal.model.JournalArticle&amp;quot;,
      &amp;quot;indexer.class.name=com.liferay.portlet.documentlibrary.model.DLFileEntry&amp;quot;
   },
   service = IndexerPostProcessor.class
)
public class MultipleEntityIndexerPostProcessor
   implements IndexerPostProcessor {

   @Override
   public void postProcessContextBooleanFilter(
         BooleanFilter booleanFilter, SearchContext searchContext)
      throws Exception {

   }

   @Override
   public void postProcessContextQuery(
         BooleanQuery contextQuery, SearchContext searchContext)
      throws Exception {

   }

   @Override
   public void postProcessDocument(Document document, Object obj)
      throws Exception {

   }

   @Override
   public void postProcessFullQuery(
         BooleanQuery fullQuery, SearchContext searchContext)
      throws Exception {
      searchContext.setGroupBy(createGroupBy());
   }

   @Override
   public void postProcessSearchQuery(
         BooleanQuery searchQuery, BooleanFilter booleanFilter,
         SearchContext searchContext)
      throws Exception {

   }

   @Override
   public void postProcessSearchQuery(
         BooleanQuery searchQuery, SearchContext searchContext)
      throws Exception {

   }

   @Override
   public void postProcessSummary(
      Summary summary, Document document, Locale locale, String snippet) {

   }

   private GroupBy createGroupBy(){
      GroupBy groupBy = new GroupBy(&amp;quot;entryClassName&amp;quot;);
      groupBy.setSize(5);
      return groupBy;
   }
}
&lt;/pre&gt;</summary>
    <dc:creator>Stephan Neese</dc:creator>
    <dc:date>2019-01-28T15:50:54Z</dc:date>
  </entry>
</feed>
