Legacy Knowledge Base
Published Jun. 30, 2025

Dynamic Blueprint parameters with Search API

Written By

Daniel Carrillo Broeder

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • Blueprints offer static filtering by field values, but a dynamic approach is needed where search fields enable filtering based on user-provided values for specific structure fields, Is possible to provide custom parameters to Search Blueprints?
    • How can I create a search experience that allows filtering content from a specific structure based on the values of its fields, using a dedicated search input for each field?

Environment

  • Quarterly Releases 2024.Q3+

Resolution

Dynamic filtering by structure fields can be achieved using Blueprints and the Search headless API:

  1. Create the Blueprint:

    • Add a parameter in the Blueprint configuration, prefixed with search.experiences.* (e.g., search.experiences.fieldName). This parameter will hold the value entered by the user in the search input.
    • parameter_config.png
    • In the Query Builder, under "Paste Any Elasticsearch Query" or "JSON element", insert ${search.experiences.fieldName} in the code as a variable.
      • This integrates the parameter's value into the search query.
    • paste_any.png
    • Adjust "Query Settings" as needed to refine the search behavior.
    • Test the Blueprint by setting the variable directly within the Blueprint preview.
    • context_attrs.png
    • Configure and copy the External Reference Code (ERC) for API usage.
  2. Access the Search Headless API:

    • Enable the Release Feature Flag LPS-179669.
    • Use the postSearchPage endpoint of the Search headless API (ensure the feature flag is enabled). This endpoint allows executing searches based on Blueprints.
    • Include the parameter nestedFields=embedded to retrieve embedded objects (content). This ensures that the structure's fields are included in the search results.
    • In the request body, provide a JSON structure containing the variable with the value to filter by (e.g., {"fieldName": "your_value"}). Replace fieldName with the actual name you used in the Blueprint configuration and your_value with the desired filter value.
    • The API response will return search results filtered based on your provided parameter.
    • apisearch.png

Alternative Approaches:

  1. Headless Delivery API for Web Content Filtering: Explore the headless APIs specifically designed for filtering web content by structure fields, like headless delivery API.

  2. Nested Custom Filters: Consider using nested Custom Filters for a more integrated approach to filtering within the search interface.

  3. Custom Facets: Utilize Custom Facets to provide users with interactive filtering options based on structure field values.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base