Hide image formats to be returned in search result
Written By
Rishabh Agrawal
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
-
When users search for a specific keyword (let's say fav) using the Liferay search bar portlet, the search result shows each and every content with the keyword fav that are Web Content, Images, users, etc.
- The expectation is to hide image formats such as (png, gif, jpg, jpeg) to be returned in the result when searched with any keyword.
- However, other document formats like pdf, docx, pptx should be displayed on the search result portlet.

Environment
- Liferay DXP 7.2
- Liferay DXP 7.3
Resolution
- The expected behavior is achievable by creating a folder facet and changing the necessary permissions of the roles associated with the users.
- Below are the step needed to be followed to achieve the required behavior:
- Add a 'Folder Facet' from widgets.
- Create a folder in the 'Documents and Media' portlet and keep all the images(png,gif, jpg, jpeg) in that folder.
- Uncheck the 'View' permission of the Guest role and other roles from the permissions of the above created folder based on the requirement.
- Keep all other document formats such as pdf, docx, pptx, xlsx under the 'Document' section (outside of any folders).
-
Result: Search with the keyword (let's say it's 'fav') and see that all the documents are returned in search result with the logged in user. But when the Guest user searches with the same keyword then pdf and xlsx documents are visible, but images.
- Video Link: https://drive.google.com/file/d/180J4d6CZzcwGwHU82YuFZwjeSfyjhUI0/view?usp=sharing
Did this article resolve your issue ?