<?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>Liferay 7.4 Search Portlet -search with only fileextension and expando</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121535461" />
  <subtitle>Liferay 7.4 Search Portlet -search with only fileextension and expando</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121535461</id>
  <updated>2026-04-06T20:52:01Z</updated>
  <dc:date>2026-04-06T20:52:01Z</dc:date>
  <entry>
    <title>RE: RE: Liferay 7.4 Search Portlet -search with only fileextension and expando</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121537287" />
    <author>
      <name>srini vasulu</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121537287</id>
    <updated>2022-10-14T16:45:34Z</updated>
    <published>2022-10-14T15:54:53Z</published>
    <summary type="html">&lt;p&gt;But in ,&lt;/p&gt;
&lt;p&gt;below ticket &lt;a
    href="https://liferay.dev/ask/questions/development/liferay-7-1-filtering-search-results-by-specific-custom-field-1"&gt;Liferay
    7.1 - Filtering search results by specific custom field&lt;/a&gt; we can
  add the below code to fileter but  &lt;/p&gt;
&lt;p&gt;searchContext object creating in SearchContextFactoryImpl class and
  how we can add it?&lt;/p&gt;
&lt;pre&gt;
BooleanClause expandoClause = BooleanClauseFactoryUtil.create(&amp;lt;expando field name&amp;gt;, &amp;lt;your value&amp;gt;,BooleanClauseOccur.MUST.toString());
searchContext.setBooleanClauses(new BooleanClause[]{expandoClause});&lt;/pre&gt;</summary>
    <dc:creator>srini vasulu</dc:creator>
    <dc:date>2022-10-14T15:54:53Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 Search Portlet -search with only fileextension and expando</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121535949" />
    <author>
      <name>Russell Bohl</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121535949</id>
    <updated>2022-10-13T16:15:16Z</updated>
    <published>2022-10-13T13:36:14Z</published>
    <summary type="html">&lt;p&gt;Hi Srini, first I'm going to suggest that you get away from the
    long&lt;a
    href="https://help.liferay.com/hc/en-us/articles/360029096771-Search-Portlet-in-Liferay-DXP-7-2"&gt; deprecated&lt;/a&gt;&lt;a
    href="https://help.liferay.com/hc/en-us/articles/360029096771-Search-Portlet-in-Liferay-DXP-7-2"&gt;search
  portlet&lt;/a&gt; and use the &lt;a
    href="https://learn.liferay.com/dxp/latest/en/using-search/search-pages-and-widgets.html"&gt;search
    page with its widgets&lt;/a&gt;. It's quite possible that on 7.4 you can
  achieve what you want with a &lt;a
    href="https://learn.liferay.com/dxp/latest/en/using-search/search-pages-and-widgets/search-results/filtering-search-results.html"&gt;custom
  filter&lt;/a&gt; if you use the search page and widgets--this would
  eliminate a code customization for you so it's worth exploring.We've
  documented some &lt;a
    href="https://learn.liferay.com/dxp/latest/en/using-search/search-pages-and-widgets/search-results/custom-filter-examples.html"&gt;custom
    filter examples&lt;/a&gt; to help folks get started.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>Russell Bohl</dc:creator>
    <dc:date>2022-10-13T13:36:14Z</dc:date>
  </entry>
  <entry>
    <title>Liferay 7.4 Search Portlet -search with only fileextension and expando</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121535460" />
    <author>
      <name>srini vasulu</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121535460</id>
    <updated>2022-10-12T21:52:43Z</updated>
    <published>2022-10-12T19:21:44Z</published>
    <summary type="html">&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;I am upgrading from 6.2 to 7.4.x and in 6.2 we added some of the
  custom fileds with extension, expand and added that values to
  serviceContext. here service context object is created in
  jsp(main_search.jspf) page and using hook implementd like below. but
  in 7.4 i am not able to add that because of servicecontext object
  created in liferay class. for that we don't have option to write the
  hook to SearchDisplayContext class.&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-java"&gt;if(Validator.isNotNull(Type) &amp;amp;&amp;amp; Type != &amp;quot;&amp;quot;){
		Query pbsubmittalTypeQuery = StringQueryFactoryUtil.create(&amp;quot;expando/custom_fields/Type:&amp;quot;+ &amp;quot;\&amp;quot;&amp;quot;+Type+&amp;quot;\&amp;quot;&amp;quot;);
		BooleanClause pbsubmittalTypeClause = BooleanClauseFactoryUtil.create(searchContext, pbsubmittalTypeQuery, BooleanClauseOccur.MUST.getName());
		booleanClauseList.add(pbsubmittalTypeClause);
	} 
	
if(Validator.isNotNull(fileExtension) &amp;amp;&amp;amp; fileExtension != &amp;quot;&amp;quot;){
	Query fileExtensionQuery = StringQueryFactoryUtil.create(&amp;quot;entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry +extension:&amp;quot;+fileExtension);
	BooleanClause fileExtensionClause = BooleanClauseFactoryUtil.create(searchContext, fileExtensionQuery, BooleanClauseOccur.MUST.getName());
	booleanClauseList.add(fileExtensionClause);
} 
if(booleanClauseList.size()&amp;gt;0){
	BooleanClause[] booleanClause = new BooleanClause[booleanClauseList.size()];
	booleanClause = booleanClauseList.toArray(booleanClause);
	searchContext.setBooleanClauses(booleanClause);
} &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any suggition how we can add conditions in 7.4?&lt;/p&gt;</summary>
    <dc:creator>srini vasulu</dc:creator>
    <dc:date>2022-10-12T19:21:44Z</dc:date>
  </entry>
</feed>
