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

StringQuery does not support query visitor

    Details

      Description

      Background

      com.liferay.portal.kernel.search.generic.StringQuery is meant to support "raw" searches means the input is not transformed, but parsed as-is by the underlying search engine connector.

      However it does not override the accept method so it goes to BaseQueryImpl which returns null and this is generating incorrect search results depending on the way the StringQuery is used because the related StringQueryTranslator implementation(com.liferay.portal.search.solr.internal.query.StringQueryTranslatorImpl or com.liferay.portal.search.elasticsearch.internal.query.StringQueryTranslatorImpl is not invoked.

      Steps to Test

      1. Create 2 wikis or blogs or whatever asset which has as a title field in the search index with title "java" and "eclipse"
      2. Create another asset with an arbitrary title
      3. Execute the following Groovy-script from the Server Admin:
        import com.liferay.portal.kernel.search.SearchContext;
        import com.liferay.portal.kernel.search.IndexSearcherHelperUtil;
        import com.liferay.portal.kernel.search.generic.StringQuery;
        import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
        
        SearchContext searchContext = new SearchContext();
        
        searchContext.setCompanyId(CompanyThreadLocal.getCompanyId());
        
        StringQuery stringQuery = new StringQuery("title:(java OR eclipse)");
        
        out.println("Search Count = " + IndexSearcherHelperUtil.searchCount(searchContext, stringQuery));
        

      Expected Result: Search Count = 2
      Actual Result: Search Count = 0

      Result is the same when using Solr.


      Solution Notes
      https://github.com/liferay/liferay-portal/blob/7.0.x/portal-kernel/src/com/liferay/portal/kernel/search/generic/StringQuery.java

      /**
       * Provides support for parsing raw, human readable query syntax. No
       * transformation is made on user input.
       *
       * <p>
       * The actual query syntax and any further processing are dependent on your
       * search engine's implementation details. Consult your search provider's
       * documentation for more information.
       * </p>
       *
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              raven.song Raven Song
              Reporter:
              tibor.lipusz Tibor Lipusz
              Participants of an Issue:
              Recent user:
              Brian Wulbern
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 45 weeks, 2 days ago

                  Packages

                  Version Package
                  7.0.0 DXP FP26
                  7.0.X EE
                  7.0.4 CE GA5
                  Master