Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-99

Allow default sort order

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.2
    • 1.2
    • search
    • None

    Description

      The current search throws an "ArrayIndexOutOfBoundsException" if you specify a sort field but do not include an order. This is anoying and difficult to debug (when you are starting)

      Here is a patch to avoid the exception and use the default sort order if you only specify a field. I'm not sure the 'null' case was even possible in the current code:

      Index: QueryParsing.java
      ===================================================================
      — QueryParsing.java (revision 494681)
      +++ QueryParsing.java (working copy)
      @@ -186,13 +186,12 @@
      }

      // get the direction of the sort

      • str=parts[pos];
      • if ("top".equals(str) || "desc".equals(str)) { - top=true; - }

        else if ("bottom".equals(str) || "asc".equals(str))

        { - top=false; - }

        else {

      • return null; // must not be a sort command
        + // by default, top is true, only change it if it is "bottom" or "asc"
        + if( parts.length > pos )
        Unknown macro: {+ str=parts[pos];+ if ("bottom".equals(str) || "asc".equals(str)) { + top=false; + } }

      Attachments

        1. DefaultSortOrder.patch
          8 kB
          Ryan McKinley
        2. DefaultSortOrder.patch
          5 kB
          Ryan McKinley
        3. DefaultSortOrder.patch
          0.7 kB
          Ryan McKinley

        Activity

          People

            Unassigned Unassigned
            ryantxu Ryan McKinley
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: