Search Tuning: Customizing Search Results

Starting with Liferay DXP 7.2 Service Pack 1, new search tuning features are available for administrative Users: Custom Result Rankings is one of them.

Result Rankings provides a brute force method for intervening into the relevance scoring of the search engine, by doing these things:

  1. Designate that certain results should appear at the top of the results if they are matched with a certain keyword. This is the idea of pinning results to the top of the results list.

  2. By contrast, hide results that shouldn’t appear in certain searches at all.

  3. Add results that aren’t normally returned by searching a certain keyword.

  4. Re-order pinned results with a drag-and-drop interface.

Result Rankings let you pin, hide, and add search results for a given set of keywords. These rankings apply only to searches using the newer search widgets (Search Bar, Search Results, etc.). The rankings you customize do not apply to the legacy Search portlet results or to the individual application search bars.

Figure 1: The Lunar Resort wants to tweak these results: pin the Activities page to the top, and hide the legal content entirely.

Figure 1: The Lunar Resort wants to tweak these results: pin the Activities page to the top, and hide the legal content entirely.

Availability

Search tuning features like Result Rankings are only supported when using Elasticsearch as the search engine. If you’re using Solr, make sure you disable the search tuning features (Synonym Sets and Result Rankings) when you upgrade your installation to Liferay DXP Service Pack 1 (Fix Pack 2).

Results Rankings was added in Liferay DXP 7.2 Service Pack 1.

Requirements and Limitations

Result Ranking entries are configured in a Virtual Instance, but are not applied only to that Virtual Instance. Instead, custom rankings made in one virtual Instance are shared across all Virtual Instances in the deployment, and even across separate deployments sharing an Elasticsearch cluster (in a multi-tenant scenario). Therefore, Result rankings shouldn’t be used when connecting multiple Liferay DXP deployments to the same Elasticsearch cluster unless you intend for the same Result rankings to apply to every Liferay DXP deployment. See LPS-101291 for more information.

An existing Result Ranking cannot be renamed. Renaming requires recreating the ranking under a different name. See LPS-96357 for more information.

Creating and Managing Result Rankings

To manipulate result rankings, create a new Alias containing the keywords/search terms you want to intercept. Perform a search to get results (you can also do a separate search if you want to grab results that haven’t even been returned during a natural search for the alias keywords). Once you have the results, choose to pin, hide, re-order, or add results as you please.

To create a new Result Rankings Alias:

  1. Navigate to Control Panel → Search Tuning → Result Rankings.

  2. Click the Add button (Add).

  3. On the New Ranking screen, enter one of the keywords or search phrases you want to intercept (it can be a phrase, instead of just one word; and don’t worry, you can add more later) in the Search Query field.

    Click Customize Results.

A search query is executed. The results are displayed and the tools for pinning, hiding, and adding results are made available. Re-ordering becomes possible after at least one result is pinned. First, consider whether to add one or more Aliases.

Adding Aliases

The Customize Rankings screen is ready to use, but any intervention only applies to the search query you initially entered in the New Ranking screen. To apply the customized rankings to additional search terms, add them as Aliases.

  1. In the Aliases field, enter the search term to add as an Alias.

    Warning: Do not use quotes in your alias terms.

  2. To submit the search term as an alias, click Enter or a comma in the Aliases field. You can Add multiple aliases here.

    Figure 2: Apply your custom rankings to matched results of additional search terms.

    Figure 2: Apply your custom rankings to matched results of additional search terms.

Note that results not manipulated manually here are returned as usual when the alias term is queried for in the Search Bar.

Now you can customize the rankings.

Activating and Deactivating Aliases

Available as of Liferay DXP 7.2, SP2

You can activate or deactivate existing aliases as you have need for them to take effect:

  1. Find the Active alias and open its editor screen.

  2. Click the toggle switch currently labeled Active.

Duplicate active aliases are not allowed, but you can deactivate an alias and then create a duplicate. After deactivating an alias, you can only reactivate it after deactivating any active duplicates.

Pinning and Hiding Results

To pin or hide rankings, hover over the result of interest: two icons appear, one for pinning and one for hiding. Click the one that applies. Otherwise click the Actions button (Actions), and select Pin Result or Hide Result. Once you select either option, it’s applied immediately. A pinned result moves to the top of the list, and a hidden result disappears. Repeat the action as many times as necessary.

If you’re done customizing the results, click Save, and it’s applied immediately.

Figure 3: Pin results to the top of the Search Results list.

Figure 3: Pin results to the top of the Search Results list.

Adding Results

To add a result that was not returned by searching for the first keyword or phrase, click the Add Result button and search for whichever asset you want to pin.

Figure 4: Add results that arent normally returned.

Figure 4: Add results that aren't normally returned.

Click Save if you’re done customizing results.

Re-Ordering Pinned Results

To re-order pinned results (results that are not pinned cannot be re-ordered), click the handle icon, drag the result, and drop it in the preferred location in the list.

Figure 5: Re-order the pinned rankings if you want to emphasize or de-emphasize certain results.

Figure 5: Re-order the pinned rankings if you want to emphasize or de-emphasize certain results.

Once finished customizing result rankings, click Save.

Result Rankings Scope and Permissions

Because configuration of Result rankings happens at the virtual instance scope, there are scoping and permissions behaviors to be aware of.

Scope is disregarded for pinned results: Pinned results existing in Site A always appear in searches from Site B, even if the Search Bar Scope is set to This Site.

Search from Result Rankings is global: When searching for results in Result Rankings admin, relevant results from all sites are returned.

Permissions are applied as usual: If a User doesn’t have permission to see an asset, pinning it does not make it appear in the search results for that User.

Result Rankings Aliases versus Synonyms

Since both are new features without precedent in Liferay DXP, there can be confusion over Result Rankings Aliases and Synonyms. Synonyms expand the search to include results matched by additional (synonymous) keywords, so more results are returned if there are matches to the synonyms.

Result Rankings Aliases are just keywords that also have the particular ranking interventions applied to them. Only the searched keyword is matched to results, and then, the pins, hides, re-ordering, and additional results take effect after that. Of course, if you add a Synonym Set that includes an identical set of search terms as the Result Ranking you configure, the features can be used together. All the synonymous terms return the same result set, with the customized rankings applied on top.

Known Issues

There are several known issues and planned improvements for Result Rankings. See LPS-99540 for the complete list.

Was this article helpful?
0 out of 0 found this helpful