Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-67848

Search portlet invokes FacetedSearcherImpl.search() 8 times for single page rendering

    Details

      Description

      While using APM tool to monitor Liferay, I noticed that when using Search portlet, the ES search index gets queried multiple times (8 times in my out-of-the-box setup). I'd expect the index to be queries only once, for best performance.

      This is due to the fact that the /init.jsp initializes JSP variable searchDisplayContext and the class SearchDisplayContext is written in a such way that in the constructor of the class following code is always executed:

      public SearchDisplayContext(
      			...
      		throws Exception {
          ...
          Hits hits = facetedSearcher.search(searchContext);
          ...
      
          _hits = hits;
          _searchContext = searchContext;
          _searchContainer = searchContainer;
      }
      

      /init.jsp is included from multiple JSPs throughout the Search portlet (using JSP directive <%@ include file="/init.jsp" %>). This include is also used from every JSP for all the facets being rendered, so the constructor gets called for every such JSP, querying index multiple times. In my test setup, each such invocation takes 20ms, which slow the performance of Search portlet considerably (20ms if written correctly vs. 8 x 20ms = 160ms now).

      This can even result into behavior where different parts of the output work with different search results, if index changes between the individual JSP includes.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              andre.oliveira André Ricardo Barreto de Oliveira
              Reporter:
              josef.sustacek Josef Šustáček
              Participants of an Issue:
              Recent user:
              Esther Sanz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                4 years, 21 weeks, 4 days ago

                  Packages

                  Version Package
                  7.0.X EE
                  Master