Introduction
Liferay provides the Elasticsearch framework to implement search functionality. We can use Liferay’s search bar and search result widget to get the search results. We can quickly find information as we need across documents, web content, users, and other assets. When working with Liferay search, two important concepts come into play: Search Filters and Search Facets.
In this blog, you will learn what search filters and facets are, how they work in Liferay, and their key differences.
Prerequisites
Liferay DXP/Portal
Environment Requirements
Java
Liferay
What is Search Filter?
Search filter works to filter the large collection of data and give you the exact data that you need. It is a condition applied to the search query that narrows down the results. Basically, it returns only the filtered data that you need after passing the search query.
Filter mainly applies to fields indexed as keywords in Liferay DXP’s search. Unlike facets, filters don’t provide counts or categories; they simply reduce the dataset. It is not visible to the user; it is applied by the system or developer. We can apply many filters in the query, like status: approved, mimeType: application/pdf, siteId:20125, etc.
When to Use Search Filters :
Use filters when you need to apply system-level restrictions or enforce business rules silently in the background. These are not shown to the user.
Using Search Filters:
To apply a filter on the search results, we need to use Liferay’s custom search filter widget and pass the condition in the search query.
To implement a search filter on your search, follow the steps below :
Open your page in edit mode, add the following widgets :
Search bar : To pass the search query
Search results : To render the search results
Custom filter : To apply a filter to the search results
- Open the configuration settings of the custom search filter.
It gives many options to configure the filter on the search, like we can pass the field name and its value to get only those results.
For now, we pass the folder ID of the document and media to get the data from a particular folder. Add values below in the configuration.
Filter Field: folderId
Filter Value: ID of your folder
Filter Query Type: Match
Occur: Filter
- If you want to hide this widget from the user, make the Invisible check box true and click on the save button.
- Now, when you search for anything from the search bar, the search results display data only of that particular folder.
What is Search Facet?
A Search Facet is a UI-driven search filter that groups results into buckets with counts. Facets don’t directly restrict results until a user selects a value. Once selected, the facet option becomes a filter in the search query.
A Search Facet is essentially an aggregation that groups results into categories and shows counts for each. For example, results can be grouped by type (document, web content), tags, categories, or modified date. Users can then click these options to refine their search results interactively.
When to Use Search Facets :
Use facets when you want to give users control over narrowing their search. Facets appear as visible filters (checkboxes, lists, date pickers) and let users refine their results.
Using Search Facets :
Liferay provides many types of search facets, like category facet, tag facet, folder facet, type facet, etc. Every facet is useful to narrow down the search results.
For now, we will add the category facet and tag facet to narrow down the results that we get after applying the filter. To implement this, follow the steps below :
Add the Category facet and tag facet to your page.
- Now you can narrow down the search results based on their category and tags.
Conclusion
In Liferay search filter and search facet both refine search results. They work with different purposes: filters are silent, system-applied tools that work behind the scenes to apply business rules and restrict data based on specific criteria like status or folder ID, whereas facets are user-facing, interactive controls that categorize results into visible buckets with counts, such as by tag or category, and allow users to explore and narrow down results dynamically.

