How to Filter Web Content by Tag or Structure ID Using Liferay Blueprint JSON Element

Author: Ajay Choudhary

Liferay Version: 7.4

This guide explains how to configure Liferay Blueprint to filter web content articles based on tag or structure ID using a custom JSON element.

Create a Liferay Blueprint

  1. Go to Control Panel > Search Experiences > Blueprints.
  2. Click Add to create a new blueprint.
  3. Provide a name, for example: News or Structured Content.

Add a Custom JSON Element

  1. In the Blueprint editor, click the + icon.
  2. Select Custom JSON.
  3. Add the following JSON to filter articles tagged with news or having a specific structure key:
{
  "must": [
    {
      "bool": {
        "should": [
          {
            "term": {
              "assetTagNames": "news"
            }
          },
          {
            "term": {
              "ddmStructureKey": "237068"
            }
          }
        ]
      }
    }
  ]
}
  1. Click Save to apply the JSON.

Attach the Blueprint to a Search Page

  1. Open the page that uses the Search Results widget.
  2. Click the Options icon and choose Configuration.
  3. Select the newly created blueprint from the dropdown.
  4. Save the configuration.

Notes

This approach allows you to combine tag-based and structure-based filtering using a logical OR condition inside Liferay’s search framework.

Also Read: How to Fetch a Category Name Using Category ID in Liferay with FreeMarker

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

close
Thanks !

Thanks for sharing this, you are awesome !