How to use multiple facets of the same type
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
- Add 2 or more Facet Widgets of the same type to a page, for example Category Facet.
- If you make a search and select a facet value in one of the widgets, the same facet value in the other widgets will be selected as well.
- How can I have multiple facets of the same type and achieve a combining AND behavior?
-
Facet 1 (from Facet Widget 1) AND Facet 2 (from Facet Widget 2) AND ...
Resolution
-
Selecting a facet term adds a new parameter to the the URL. For instance, for a Category Facet you get:
/search?q=test&category=1234
.
- The name of this parameter is always the same by default for Facets of the same type, but it can be changed in the Facet Configuration menu, under "{{Type}} Parameter Name" (where {{Type}} corresponds to the type of Facet: Category, Tag, etc.).
- If the parameter names are not the same for the Facets, they will appear in the URL and the search result will match all of the filter criteria.
- For example, if the parameter name for Facet 1 is main-category, and for Facet 2 is sec-category, the URL will have this format:
/search?q=test&main-category=1234&sec-category=4321
.
- Note that, when selecting values from the same Facet Widget, it gives a combining OR behavior. So by adding further Facet Widgets of the same type and customizing their "{{Type}} Parameter Name" allows any boolean combining behavior.
- For example, (Facet 1 OR Facet 2 OR Facet 3) AND (Facet 4 OR Facet 5).
Did this article resolve your issue ?