Legacy Knowledge Base
Published Jun. 30, 2025

Search results can be incomplete when highlighting is enabled

Written By

Brian Suh

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

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

 

Did this article resolve your issue ?

Legacy Knowledge Base