Legacy Knowledge Base
Published Jun. 30, 2025

How to display the results when searching different Elasticsearch indices

Written By

Jose L. Bango

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 the Low Level Search Options feature, you are able to search alternate indices by performing a federated search.
  • For regular searches (Liferay results), you can use SearchResultSummaryDisplayContex to get the data and display the search results. That is what you get in the entries object you can see in the out-of-the-box widget display templates. However, this is not available for alternate indices.
  • Then, how can you access the documents' fields and display those results?

Environment

  • DXP 7.3, DXP 7.4
  • 2023.Q3, 2023.Q4, 2024.Q1

Resolution

  • You can leverage SearchResultsPortletDisplayContext to access the Search Engine Documents and the iterate over them.
  • Here’s an example of how to do that within in a Search Results Widget Display Template:
    <div class="search-total-label">
    ${languageUtil.format(locale, "x-results-for-x", [searchContainer.getTotal(), "<strong>" + htmlUtil.escape(searchResultsPortletDisplayContext.getKeywords()) + "</strong>"], false)}
    </div>

    <div class="display-list">
    <ul>
    <#list searchResultsPortletDisplayContext.getDocuments() as document>
    <#assign searchResultSummaryDisplayContext = searchResultsPortletDisplayContext.getSearchResultSummaryDisplayContext(document) />
    <li><strong>Title: </strong>${document.get("title_es_ES")}
    <ul>
    <li><strong>Modified:</strong> ${document.get("modified")}</li>
    <li><strong>Id:</strong> ${document.get("articleId")}</li>
    <li><strong>Site Id:</strong> ${document.get("groupId")}</li>
    </ul>
    </li>
    </#list>
    </ul>
    </div>

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base