legacy-knowledge-base
公開されました Sep. 10, 2025

How to set up Search Blueprints to be used with Search headless API

written-by

Daniel Carrillo Broeder

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

learn-legacy-article-disclaimer-text

Issue

  • You do not find a suitable headless API or is not still developed by Liferay so you would like to create your own search blueprint and invoke it easily from Search API.
    • For example, retrieve draft or pending web content articles based on a structure field ( Feature Request ).

Environment

  • Quarterly Releases from 2024.Q3+

Resolution

  1. Starting from 2024.Q3, you can enable the release feature flag feature.flag.LPD-11232=true and feature.flag.LPS-179669=true in portal-ext.properties to be able to invoke your custom search blueprints from headless API.
  2. Create your custom search blueprint with any kind of search, and save the external reference code (ERC).
  3. Access the search API and execute GET /v1.0/search (getSearchPage) adding, at least, this parameters:
    • blueprintExternalReferenceCode : <ERC> - Custom Blueprint reference.
    • emptySearch: true - Enables empty search.
    • nestedFields: embedded - Get additional data of the result item.

 

Example - Obtain web contents of a given site in any status based on a custom text structure field 'fieldSample=sample'

  1. Verify feature flags are added to portal-ext.properties
  2. Create a custom structure and add some web contents having fieldSample with value 'sample'
  3. Create a new Blueprint:
    • Query Settings
      • Set "Web Content Article" as searchable type.
      • Disable all search query contributors.
    • Query Elements
      • Paste a 'MUST' elasticsearch query to filter web contents having fieldSample=sample. Could be similar to the following json (verify elasticsearch index to check the IDs and field name/value and adapt this code to your specific environment configuration):
      • {
        "nested":{
        "path":"ddmFieldArray",
        "query":{
        "bool":{
        "must":[{
        "term":{
        "ddmFieldArray.ddmFieldName":"ddm__keyword__12345__fieldSample_en_US"
        }
        },
        {
        "term":{
        "ddmFieldArray.ddmFieldValueKeyword_en_US":{
        "value": "sample"
        }
        }
        }]
        }
        }
        }
        }
      • Add a "Limit Search to These Sites" element and select a site.
    • (Optional) Modify the ERC to 'custom-erc' and save.
  4. Test it with search API

Additional Information

did-this-article-resolve-your-issue

legacy-knowledge-base