Introduction
Creating a blueprint in Liferay allows you to customize the portal’s search behavior according to your users’ needs.
Prerequisites
- Liferay DXP
- Basic knowledge of Liferay
What is Blueprint?
- A Blueprint in Liferay is a design plan for customizing search behavior.
- It enables you to tailor the search experience without writing code.
- If you need control over what is searched or how the search should work, Blueprints is the essential feature you should use.
- Instead of relying on code-heavy implementations, Blueprint provides an alternative approach for users who require near-complete control over the search query without deploying custom code.
- Blueprints offer a UI-based configuration experience that can address almost every use case.
Things possible through the blueprint
Using the blueprint, below things are possible
- Use the Query Builder to build Blueprints visually
- Compose Blueprints with JSON in the Liferay UI
- Leverage out-of-the-box Elements to simplify Blueprint creation
- Use Elasticsearch queries as custom Elements
- Create custom Elements from Elasticsearch queries
- Create custom JSON Elements for my Blueprints
- Create advanced Blueprints settings by editing the JSON directly
- Choose which Liferay Entities are searchable when the Blueprint is applied
- Choose whether to include clauses from Liferay’s Indexer Framework and individual query clause contributors
- Using JSON, configure advanced settings: Aggregations, Sorts, Highlights, etc.
How can we use the blueprint?
Step 1 : Create content and a search page to configure the blueprint and view the results.
- Create three web contents.
- Create the vocabulary ‘News’ and the following categories
- Assign each category to the related web content
- For the ‘Sports News’ web content, assign the category “Sports”.
- For the ‘Technology News’ web content, assign the category “Technology”.
- For the ‘Health News’ web content, assign the category “Health”.
- Create a content page. Add a search bar and search results to the page, and then publish the page.
- When we search for the keyword ‘news,’ It will show these results. You’ll notice that the results include web contents and the page itself as the first record.
- Only web content should be visible in the search results (excluding pages and other records).
- Records categorized under “Sports” should appear first when searching for the keyword ‘news.’
- Log in as an administrator and navigate to Control Panel > Applications > Blueprints.
- Click on the Add (+) icon and Enter the title and description.
- On the right side, you will see the blueprint elements. Select ‘Boost Contents in a Category by Keyword Match.’
- Provide the Asset Category Name(ID) (e.g., Sports; you can type it in, and suggestions will appear) and the keywords as “news.” Set the boost value (a higher boost value will prioritize it in the results) and then save it.
- To ensure that only web content is visible when searching for any keyword, use the Query Settings. Select Asset Type as Web Content Article and save the changes.
Step 4 : Configure the blueprint on a page
- Edit the content page, from components, select blueprint options, drag and drop to the page, and select created blueprint.
- Click on Configuration.
- Select the created blueprint and publish the page.
Analyze the result
When you search for the keyword ‘News,’ only web content will be displayed, with items categorized under ‘Sports’ appearing first.
Here, you can see that only data from the “Sports News” category is visible first, and only web contents are shown. This demonstrates the advantage of using blueprints, you can utilize them in this way.
You can explore many other elements of blueprints. This concludes the overview of blueprints and how to use and configure them.
Conclusion
Blueprints in Liferay offer a powerful way to customize and refine search results to meet specific needs. By creating and configuring blueprints, you can enhance the relevancy of search results, ensuring that users find the most relevant content quickly.