Issue
- Is it possible to hide specific pages from search results?
- For example, we have a site with Page A and Page B. Both pages need to remain public, but we only want Page B to show up in the results when users perform searches.
Environment
- DXP 7.2
Resolution
Important note: Instead of using the "Custom Filter" widget, it is also possible to make use of the "Search Blueprints" functionality, which allows you to hide the results with a specific tag using the "Hide Tagged Contents" element, for more information see:
- https://learn.liferay.com/dxp/latest/en/using-search/liferay-enterprise-search/search-experiences/search-blueprints-elements-reference.html#hide-some-results => "Hide Tagged Contents"
It is possible to accomplish this end goal by leveraging the Custom Filter Widget's functionality
One set of possible steps to accomplish the end goal for the example described above would be:
- Add a "Search > Custom Filter" portlet to the search page where results will be displayed
-
Select ⠇> Configuration for the Custom Filter, then configure and save the following values:
- Filter Field:
assetTagNames - Filter Value:
tagforhiddenpages - Filter Query Type:
Match - Occur:
must_not - [Optional]: To make the filter both invisible and un-editable to non-admin users, you can also select the "Invisible" and "Immutable" checkboxes
- Filter Field:
- Edit the SEO Categorization tags for Page A to include the tag
tagforhiddenpages - Once all changes are saved, any searches for "Page" will include a result for Page B, but will exclude the result for Page A
Additional Information
- The custom filter widget can be configured to look for other Fields and Values that are not the SEO tag example above, to better fit your use case. You can see this article for information on how to view the fields/values associated to a particular Elasticsearch JSON document using the Liferay UI.
- More information can be found in the following articles: