Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-13603

Special characters escaping for full-text search

    XMLWordPrintable

Details

    Description

      Set of the dangerous special characters that should be escaped during full-text search should be defined in the documentation. Also the way how to escape them should be described.

      Example:

      // HotRodClientEntity c with following field is stored in a remote cache
      clientId = "aa*bb";
      // performed query with double backslash escaping
      FROM kc.HotRodClientEntity c WHERE ((c.realmId = :realmId0) AND (c.clientId : '*a\\*b*'))
      // result *nothing* is matched by the query
      
      // performed query with single backslash escaping
      FROM kc.HotRodClientEntity c WHERE ((c.realmId = :realmId0) AND (c.clientId : '*a\*b*'))
      // exception is thrown
      line 1:117 no viable alternative at character '*'
      line 1:117 no viable alternative at input '*'
      line 1:122 mismatched character '<EOF>' expecting '''
      org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=39 returned server error (status=0x85): org.infinispan.objectfilter.ParsingException: ISPN028526: Invalid query: FROM kc.HotRodClientEntity c WHERE ((c.realmId = :realmId0) AND (c.clientId : '*a\*b*')); Parser error messages: [[statement, selectStatement, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, relationalExpression, additiveExpression, atom, expressionOrVector, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, relationalExpression, additiveExpression, atom, expressionOrVector, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, fullTextExpression, ftBoostedQuery, ftTermOrQuery]: line 1:117 state 0 (decision=72) no viable alt; token=[@41,117:117='*',<10>,1:117], [statement, selectStatement, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, relationalExpression, additiveExpression, atom, expressionOrVector, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, relationalExpression, additiveExpression, atom]: line 1:122 mismatched token: [@43,122:122='<EOF>',<-1>,1:122]; expecting type RPAREN, [statement, selectStatement, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, relationalExpression, additiveExpression, atom]: line 1:122 mismatched token: [@43,122:122='<EOF>',<-1>,1:122]; expecting type RPAREN].
          at org.infinispan.client.hotrod.impl.protocol.Codec20.checkForErrorsInResponseStatus(Codec20.java:333)
      
      // no escaping
      FROM kc.HotRodClientEntity c WHERE ((c.realmId = :realmId0) AND (c.clientId : '*a*b*'))
      // each entity that contains a and b in clientId is matched
      

      Attachments

        Activity

          People

            fercoli@redhat.com Fabio Massimo Ercoli
            mkanis Martin Kanis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: