Issue
- With highlighting enabled, search results only shows those sentences which match. If there are no matches, it shows all sentences.
- This can affect the title, summary and other result fields.
Environment
- Liferay DXP 7.0, 7.1, 7.2, 7.3, and 7.4
- Elasticsearch
Resolution
Using portal-ext.properties configuration
-
Liferay DXP uses highlighting as delivered from Elasticsearch's Unified Highlighter. Part of this highlighter's function is breaking down the field into sentences. If no highlighted field is received from Elasticsearch, we use the default of the Description.
You may want to tune the following property in the following manner in portal-ext.properties, as it will help to return the entire description when the search term matched a word in the first sentence:
# Set the fragment size returned from the search result highlighter.
index.search.highlight.fragment.size=200 - By default, the property is set to a value of 80 chars, and can be adjusted to the desired requirements.
Using Search Blueprints Highlight configuration
Only for Liferay DXP 7.3 U6+ and Liferay DXP 7.4.
Search Blueprints requires an external plugin for Liferay DXP 7.3 U6+, while it is delivered out-of-the-box in Liferay DXP 7.4.
- Access from Global Menu → Applications → Blueprints.
- Open the Blueprint editor → Configuration tab and add a valid JSON. For example:
{ "fields": { "content${context.language_id}": {}, "title${context.language_id}": {} }, "fragment_size": 200, "number_of_fragments": 10, "post_tags": [ "</liferay-hl>" ], "pre_tags": [ "<liferay-hl>" ], "require_field_match": true } - In this case, "fragment_size" should be modified to increase the length of chars.
Additional Information