Solr
  1. Solr
  2. SOLR-589

DisMaxRequestHandler crashes on badly formed query strings ( combinations of "-" and "+" )

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2, 1.3
    • Fix Version/s: 1.3
    • Component/s: search
    • Labels:
      None
    • Environment:

      all platforms

      Description

      The DisMaxRequestHandler parser crashes on strings which contain double dashes or various combinations of - and + like:

      chocolate cookie -
      chocolate -+cookie
      chocolate --cookie
      chocolate - - cookie

      Originally found by me:
      http://mail-archives.apache.org/mod_mbox/lucene-solr-user/200806.mbox/browser

      And verified by Sean Tim:
      http://mail-archives.apache.org/mod_mbox/lucene-solr-user/200806.mbox/browser

      1. SOLR-589.patch
        4 kB
        Sean Timm
      2. SOLR-589.patch
        3 kB
        Sean Timm
      3. SOLR-589.patch
        3 kB
        Sean Timm

        Issue Links

          Activity

          Hide
          Hoss Man added a comment -

          Linking up other issues that relate to dismax not doing "the right thing" on questionable input ... at a minimum, dismax should catch any ParseException and do it's best to strip out all possibly offending chars then retry, but we can try to be more proactive and deal with each type of use case uniquely based on whatever people think the best behavior is.

          Show
          Hoss Man added a comment - Linking up other issues that relate to dismax not doing "the right thing" on questionable input ... at a minimum, dismax should catch any ParseException and do it's best to strip out all possibly offending chars then retry, but we can try to be more proactive and deal with each type of use case uniquely based on whatever people think the best behavior is.
          Hide
          Sean Timm added a comment -

          This patch strips out consecutive +/- operators, or dangling +/- operators.

          Show
          Sean Timm added a comment - This patch strips out consecutive +/- operators, or dangling +/- operators.
          Hide
          Sean Timm added a comment -

          Changed to use non-capturing groups. Also reversed the order the regular expressions are run. Both changes are for performance only.

          Show
          Sean Timm added a comment - Changed to use non-capturing groups. Also reversed the order the regular expressions are run. Both changes are for performance only.
          Hide
          Sean Timm added a comment -

          Simplified one of the regular expressions and improved performance for queries with a large number of sequential +/- operators. Added two additional test cases to test these scenarios.

          Show
          Sean Timm added a comment - Simplified one of the regular expressions and improved performance for queries with a large number of sequential +/- operators. Added two additional test cases to test these scenarios.
          Hide
          Otis Gospodnetic added a comment -

          Thanks Sean!

          Sending CHANGES.txt
          Sending src/java/org/apache/solr/search/DisMaxQParserPlugin.java
          Sending src/java/org/apache/solr/util/SolrPluginUtils.java
          Sending src/test/org/apache/solr/util/SolrPluginUtilsTest.java
          Transmitting file data ....
          Committed revision 686042.

          Show
          Otis Gospodnetic added a comment - Thanks Sean! Sending CHANGES.txt Sending src/java/org/apache/solr/search/DisMaxQParserPlugin.java Sending src/java/org/apache/solr/util/SolrPluginUtils.java Sending src/test/org/apache/solr/util/SolrPluginUtilsTest.java Transmitting file data .... Committed revision 686042.
          Hide
          Shalin Shekhar Mangar added a comment -

          Updating fix version to 1.3

          Show
          Shalin Shekhar Mangar added a comment - Updating fix version to 1.3

            People

            • Assignee:
              Otis Gospodnetic
              Reporter:
              bram de jong
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development