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

Incorrect solr query for an 'a' keyword

    Details

    • Branch Version/s:
      6.0.x

      Description

      Hi,

      I've encountered a strange behaviour of search in the liferay. It generates an incorrect query when I search for an 'a' keyword (e.g. for solr generated query look like hl.fragsize=80&fl=score&hl;.snippets=3&start=0&q=+(portletId:28)(()()()()()()()())++companyId:10132&wt=javabin&hl=true&version=2.2&rows=5)). With lucene it doesn't throw any exceptions but also it doesn't highlight 'a' symbols (tested at the liferay 6.0.6 and tomcat 6.0.29 bundle).

      By debug I've figured out, that in method
      public void addTerm(BooleanQuery booleanQuery, String field, String value, boolean like) throws ParseException
      of class
      com.liferay.portal.search.lucene.LuceneHelperImpl
      at line 132
      Query query = queryParser.parse(value);
      the parse() method returns a BooleanQuery (subquery?) if it get an 'a' as value. I thought it should return a TermQuery, doesn't it?

      Here the test program I've written:

      LuceneTest.java
      import org.apache.lucene.queryParser.QueryParser;
      import org.apache.lucene.queryParser.ParseException;
      import org.apache.lucene.util.Version;
      import org.apache.lucene.analysis.WhitespaceAnalyzer;
      import org.apache.lucene.search.Query;
      
      class LuceneTest {
       public static void main(String [] args) {
        if (args.length != 1) {
         System.out.println("Usage:nLuceneTest query");
         return;
        }
        QueryParser queryParser = new QueryParser(
         Version.LUCENE_24, "assetTagNames", new WhitespaceAnalyzer());
        
        try {
         Query query = queryParser.parse(args[0]);
         System.out.println(query.getClass().getName() + " : " + query);
        } catch (ParseException e) {
         System.out.println(e);
        }
       }
      }
      

      but it works correctly:

      C:tempjavalucene-test>java -cp .;lucene.jar LuceneTest a
      org.apache.lucene.search.TermQuery : assetTagNames:a
      

      Is this a liferay or lucene bug or something else?

      Exceptions thrown by the solr and the solr-web plugin:

      19:18:27,999 INFO [STDOUT] 19:18:27,996 ERROR [jsp:1528] Error displaying content of type com.liferay.portlet.blogs.util.BlogsOpenSearchImpl: com.liferay.portal.kernel.search.SearchException: com.liferay.portal.kernel.search.SearchException: com.liferay.portal.kernel.messaging.MessageBusException: No reply received for message: {destinationName=liferay/search_reader, responseDestinationName=liferay/search_reader/response, responseId=84722b3d-64e2-4211-b52f-73f40d5d9272, payload={companyId=10132, document=null, documents=null, end=5, id=null, ids=null, query=+(+portletId:33) +(() () () () () () () ()), searchEngineCommand=SEARCH, sorts=null, start=0}, values=null} 
      19:18:28,028 SEVERE [SolrCore] org.apache.solr.common.SolrException: org.apache.lucene.queryParser.ParseException: Cannot parse '+(+portletId:28) +(() () () () () () () ()) +companyId:10132': Encountered ")" at line 1, column 20. 
      Was expecting one of: 
          <NOT> ... 
          "+" ... 
          "-" ... 
          "(" ... 
          "*" ... 
          <QUOTED> ... 
          <TERM> ... 
          <PREFIXTERM> ... 
          <WILDTERM> ... 
          "[" ... 
          "{" ... 
          <NUMBER> ... 
           
      at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:101) 
      at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:148) 
      at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131) 
      at org.apache.solr.core.SolrCore.execute(SolrCore.java:1204) 
      at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:303) 
      at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:232) 
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) 
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) 
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) 
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) 
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) 
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) 
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) 
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) 
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) 
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 
      at java.lang.Thread.run(Thread.java:662) 
      Caused by: org.apache.lucene.queryParser.ParseException: Cannot parse '+(+portletId:28) +(() () () () () () () ()) +companyId:10132': Encountered ")" at line 1, column 20. 
      Was expecting one of: 
          <NOT> ... 
          "+" ... 
          "-" ... 
          "(" ... 
          "*" ... 
          <QUOTED> ... 
          <TERM> ... 
          <PREFIXTERM> ... 
          <WILDTERM> ... 
          "[" ... 
          "{" ... 
          <NUMBER> ... 
           
      at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:173) 
      at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:79) 
      at org.apache.solr.search.OldLuceneQParser.parse(LuceneQParserPlugin.java:119) 
      at org.apache.solr.search.QParser.getQuery(QParser.java:88) 
      at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:82) 
      ... 25 more 
      
      19:18:28,029 INFO [SolrCore] [] webapp=/solr path=/select params={hl.fragsize=80&fl=score&hl;.snippets=3&start=0&q=+(+portletId:28)++(()+()+()+()+()+()+()+())++companyId:10132&wt=javabin&hl=true&version=2.2&rows=5} status=500 QTime=2 
      19:18:28,031 INFO [STDOUT] 19:18:28,030 ERROR [SolrIndexSearcherImpl:75] org.apache.solr.client.solrj.SolrServerException: Error executing query 
      org.apache.solr.client.solrj.SolrServerException: Error executing query 
      at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:96) 
      at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:109) 
      at com.liferay.portal.search.solr.SolrIndexSearcherImpl.search(SolrIndexSearcherImpl.java:64) 
      at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.doCommandSearch(SearchReaderMessageListener.java:41) 
      at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.doReceive(SearchReaderMessageListener.java:66) 
      at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.receive(SearchReaderMessageListener.java:31) 
      at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:63) 
      at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:61) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
      at java.lang.Thread.run(Thread.java:662) 
      Caused by: org.apache.solr.common.SolrException: Bad Request 
      
      Bad Request 
      
      request: http://localhost:8080/solr/select?hl=true&hl;.fragsize=80&hl;.snippets=3&fl=score&q=+(+portletId:28) +(() () () () () () () ()) +companyId:10132&rows=5&start=0&wt=javabin&version=2.2 
      at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:343) 
      at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:183) 
      at com.liferay.portal.search.solr.server.BasicAuthSolrServer.request(BasicAuthSolrServer.java:93) 
      at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90) 
      ... 10 more 
      19:18:28,031 INFO [STDOUT] 19:18:28,031 ERROR [SearchReaderMessageListener:34] Unable to process message {destinationName=liferay/search_reader, responseDestinationName=liferay/search_reader/response, responseId=c2b64694-7947-4332-bffe-a47400b342dd, payload={companyId=10132, document=null, documents=null, end=5, id=null, ids=null, query=+(+portletId:28) +(() () () () () () () ()), searchEngineCommand=SEARCH, sorts=null, start=0}, values=null} 
      com.liferay.portal.kernel.search.SearchException: Error executing query 
      at com.liferay.portal.search.solr.SolrIndexSearcherImpl.search(SolrIndexSearcherImpl.java:77) 
      at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.doCommandSearch(SearchReaderMessageListener.java:41) 
      at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.doReceive(SearchReaderMessageListener.java:66) 
      at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.receive(SearchReaderMessageListener.java:31) 
      at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:63) 
      at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:61) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
      at java.lang.Thread.run(Thread.java:662)
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  8 years, 22 weeks, 6 days ago

                  Packages

                  Version Package