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

Incorrect results for OR queries using Solr

    Details

      Description

      OR queries like this (in Lucene syntax) doesn't return the expected results:
      title:cats title:dogs

      Steps to reproduce it:

      1. Configure the portal to use Solr.
      2. Create two contents, one with title dogs and other one with title cats
      3. Go to Control Panel/Server Administration/Scripts
      4. Select Groovy as language and execute the following script:
        import com.liferay.portal.kernel.search.BooleanQuery;
        import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil;
        import com.liferay.portal.kernel.search.Hits;
        import com.liferay.portal.util.PortalUtil;
        import com.liferay.portal.kernel.search.SearchContextFactory;
        import com.liferay.portal.kernel.search.SearchContext;
        import com.liferay.portal.kernel.search.SearchEngineUtil;
        
        searchContext = SearchContextFactory.getInstance(PortalUtil.getHttpServletRequest(actionRequest));
        
        query = BooleanQueryFactoryUtil.create(searchContext);
        
        query.addTerm("title", "cats");
        query.addTerm("title", "dogs");
        
        hits = SearchEngineUtil.search(searchContext, query);
        
        out.println("Number of resources found: " + hits.getLength());
        

      The script should print (expected result):
      Number of resources found: 2

      But it returns more results.

      Technical information
      For solr we add the companyID as a query condition but for queries like the previous one generates:
      title:cats title:dogs +companyId:XXXX

      So it returns all the objects which match with the companyId regardless of the rest of the queries conditions.

      *This doesn't occur for Lucene since we don't to filter by companyId due to it exists an index for each instance.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 34 weeks ago

                  Packages

                  Version Package
                  6.2.X EE
                  7.0.0 M4