Legacy Knowledge Base
Published Jul. 2, 2025

Sorting using localizable and indexable fields from structure is not working

Written By

Sergio Alonso

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

  • When trying to get a search result, sorted by some localizable and indexable fields defined in a structure, the configured Sort widget does not work properly.
  • The issue can be reproduced with these steps:
    1. Configure a site with two locales. For example, Spanish (default) and English.
    2. Define a structure with some localizable and indexable fields. For example, these following fields:
      articleName
      price
      The structure ID might be, for example, 1184008.
    3. Configure a Custom Filter (search widget) to filter by structure. Following our example, configure it for the structure with ID 1184008.
    4. Configure a Sort (search widget) including the previous structure fields. For example:
      Label: Name 
      Field: ddm__keyword__1184008__articleName_es_ES

      Label: Price ASC
      Field: ddm__keyword__1184008__price_es_ES+

      Label: Price DESC
      Field: ddm__keyword__1184008__price_es_ES-
    5. Execute a search using the default locale.The expected and observed behavior is that the results are correctly sorted, both for predefined Sort widget fields (relevance, title, modified+, modified-, createDate+, createDate-, userName) and the added ones (ddm__keyword__1184008__articleName_es_ES, ddm__keyword__1184008__price_es_ES+ , ddm__keyword__1184008__price_es_ES-).
    6. Change the site locale and repeat the search. The observed behavior is that the results are correctly sorted only for the predefined Sort widget fields but no for the added ones.

Environment

  • Liferay DXP 7.2, 7.3

Resolution

  • There are two key points to take into account:
    1. When configuring the Sort widget, the field values must be defined without any suffixed locale. In our example:
      Label: Name 
      Field: ddm__keyword__1184008__articleName

      Label: Price ASC
      Field: ddm__keyword__1184008__price+

      Label: Price DESC
      Field: ddm__keyword__1184008__price-
    2. Every field defined as localizable in the structure must be filled with a value on each locale translation. If you want a field to be sorted using the same value for every locale then the field must not be defined as localizable.
  • The root cause is that the sort operation adds a locale for every localizable field defined in the Sort widget configuration so it is not necessary to add one.
Did this article resolve your issue ?

Legacy Knowledge Base