Legacy Knowledge Base
Published Jul. 2, 2025

Unrelated word matches in searches

Written By

Ricardo Couso

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

  • In some rare occasions, when searching there can be unexpected results matched by title that are not related to the searched terms.
  • An example would be:
    • Search term: laces.
    • Results: laces, laced, but also lacerations.

Environment

  • Liferay DXP 7.3, 7.4

Resolution

  • In summary, this behavior occurs because:
    1. laces is analyzed as lace,
    2. lacerations is analyzed as lacer,
    3. lace is a prefix of lacer,
    4. the effective search is lace*.
  • More in detail, when indexing and search for text, Elasticsearch analyzes it according to language and produces a series of tokens, such as lacer from lacerations.
    • Example: ${elasticsearch-domain-and-port}/${liferay-index}/_analyze?source={%22analyzer%22:%22liferay_analyzer_en%22,%22text%22:%22laces,lacerations%22}&source_content_type=application/json&pretty
  • The effective search by lace* is a consequence of the type of search used for titles: match_phrase_prefix. See Change of behavior in searches after upgrading from Elasticsearch 6 to Elasticsearch 7 connector for more information about this.
  • Can this behavior be changed?
    • Not via configuration.
    • An unsupported option is referenced in the same article linked above.
      • In short, the idea would be to change the @Component property title.fields in the class FieldQueryBuilderFactoryImpl.java from name|title to just name.
      • For that, create a .config file with name com.liferay.portal.search.internal.analysis.FieldQueryBuilderFactoryImpl.config and the content title.fields="name", and place it in $LIFERAY_HOME/osgi/configs/.
      • Note: This approach is not supported and it should be thoroughly evaluated and tested if considered.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base