Create Search Blueprints For Semantic Search In Liferay DXP 7.4

blog-banner

Search Blueprints is the initial component of the Search Experiences toolkit. Blueprints allow you to personalize the search page experience to your users' needs without deploying any custom code.

What is a Blueprint?

A Search Blueprint is a design for Liferay's search functionality. The majority of consumers' search experiences start with a Search Bar. When a search phrase is input, Liferay's search infrastructure generates a complex query and sends it to the search engine. The Search Insights widget allows you to see the entire Liferay query. This query can be thought of as Liferay's default pattern for the search page, giving you control over what and how is searched.

You can modify the elastic search query that Liferay Search generates by adding your custom query and get search results based on that amended query by using the Liferay Search Blueprint.

What can I do with the Blueprints user interface?

Create an element-based Blueprint and then apply it to the page to generate a search solution. The following features are available for doing so:

lueprint-features

Blueprints are made up of Elements with some additional settings on top.

Elements

Elements are graphic building blocks that come together to construct a comprehensive plan. Each Element is accompanied by a JSON fragment describing a particular search behavior. Elements are included by default in Search Experiences, and an Element editor allows you to create or copy existing ones.

elements

Creating search blueprints

To generate search blueprints,

  • To open the Blueprints application, navigate to Global Menu ? Applications (Search Experiences).
  • To create a blueprint, click Add (+).
    blueprint-step-1 blueprint-step-2
  • In the New Search Blueprint window, specify the Blueprint's name (mandatory) and description (optional).
  • Depending on your Blueprint plan, you'll then use these menus to continue constructing the Blueprint:
    • Query Builder:Select or compose Elements for the Blueprint to add new query clauses to the search. Additional query settings can be configured in the Query Settings section.
    • Configuration:In the search, set advanced parameters (such as Sorts or Aggregations).
  • Once you've completed the initial Blueprint creation, click Save.

Using the Query Builder

Use the Query Builder to:

  • Add Blueprint Elements.
  • Select which Liferay assets should be searched for.

Add Blueprint Elements

To open the Add Query Elements sidebar, click Add (+) on the Query Elements screen.

blueprint-step-3

Expand the Element category you want to investigate Link.

Hover over the Element and click the Add button.

The Element is added to the Query Builder and ready for configuration: As an example, consider the image below, where I've added a filter by exact terms match.

blueprint-step-4

In the screenshot above, the configured element returns all layouts based on field entryClassName matches the com.liferay.portal.kernel.model.Layout.

After adding Elements, save the Blueprint.

We can also include our custom Elasticsearch query in the blueprint using the elements provided in the custom tab, as seen in the image below.

blueprint-step-5

Select which Liferay assets should be searched

Select the Liferay Asset Types to include in the Blueprint's query. Navigate to Query Settings > Searchable Types:

blueprint-step-6

The default selection includes all asset and object kinds.

To delete certain types, open the Select Types dialog box by clicking Select Asset Types, then deselect the appropriate checkboxes.
blueprint-step-7

Disabling an asset type in the Searchable Types setup implies that the query clauses normally contributed by its indexing code are excluded. The type is not searchable, and when the Blueprint is used to search, end users will not see results for the omitted type.

More information is provided below, as the Searchable Types configuration has significant ramifications for the other clause contributor setup options.

Advanced: Configuring Query Clause Contributors

Liferay's backend code (and maybe any custom applications deployed in your Liferay instance) contributes query clauses to the current search.

These clauses given by the backend can be configured using Search Blueprints. However, most users should never touch these two settings:

  • Search Framework Indexer Clauses
  • Search Framework Query Contributors

In most cases, the default settings are sufficient. If you are certain that you need to change this behavior in addition to using Searchable Types, you must first understand how these backend contributors work:

  • Use Searchable Types to prevent specific indexers from participating in the search. When you disable a type's indexer, no clauses for that type are added to the search query, even if its Query Contributors are set. Users do not see these types of results.
  • Use the Search Framework Indexer Clauses to prevent all Liferay indexers from contributing clauses to the search. The only reason to disable all indexers is to create a new search query, which also disables all Query Contributors and Searchable Assets.
  • Use the Search Framework Query Contributors section to exclude particular contributors from the search results. deactivate specific clause contributors if you want to override them with your own Blueprints configuration, or deactivate all clauses to entirely override Liferay's search behavior, including indexers and searchable types.

blueprint-step-8

Additional blueprints configuration

In addition to micromanaging the search query, add search blueprint parameters and JSON configurations for

  • Aggregation Configurations
  • Highlight Configurations
  • Sort Configurations
  • Parameter Configurations
  • Advanced Configuration

Sort Configuration

Sorts can be configured in the Search Blueprints. Sorts introduced through Search Blueprints are used in addition to those already in the search request (for example, from the Sort widget). Sorts added to a Search Blueprint, however, do not appear in the Sort widget's UI or setup screen.

Output: sort document according to createDate(Desending order).

blueprint-step-9

Applying a Search Blueprint to a Search Page

A search page does not come with a search blueprint by default. To change the Liferay search experience, a blueprint must be added to a search page. If a site has many search pages, repeat the procedures below for each page that should use a blueprint, as they must be configured separately. If you want, you can utilize various blueprints for each page.

To get the search page to follow your search blueprint,

  • Create a blueprint.
  • You can create or navigate to the search page.
  • Insert the Blueprint Options widget onto the page.
  • Click Configuration after clicking the widget's Options button (Options).
  • Select a page blueprint by clicking Select.

blueprint-step-10 blueprint-step-11

Conclusion

Liferay Search Blueprint is a powerful module that allows businesses to modify and improve the search experience within their Liferay portal. Creating a blueprint allows administrators to specify search behavior, manage what is searched and how, and improve the relevance and personalization of search results. In addition, we can define aggregate, sorting, and highlighting in our queries.

Contact us

For Your Business Requirements

Text to Identify Refresh CAPTCHA
Background Image Close Button

2 - 4 October 2024

Hall: 10, Booth: #B8 Brussels, Belgium