[ https://issues.apache.org/jira/browse/SOLR-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12463530 ]
Ryan McKinley commented on SOLR-99: ----------------------------------- I apologize... the first version does not pass ConvertedLegacyTest.testABunchOfConvertedStuff()! This second version rewrites most of parseSort() and passes the tests. I am a bit confused by the old parser because it seems to be handling a legacy paging system. The javadocs show the sort formats as: * Examples: * <pre> * top 10 #take the top 10 by score * desc 10 #take the top 10 by score * score desc 10 #take the top 10 by score * weight bottom 10 #sort by weight ascending and take the first 10 * weight desc #sort by weight descending * height desc,weight desc #sort by height descending, and use weight descending to break any ties * height desc,weight asc top 20 #sort by height descending, using weight ascending as a tiebreaker *</pre> This puts the "count" in the SortSpec.num field. SortSpec.getCount() is only called from: SolrPluginUtils.doSimpleQuery(). Is this a mistake? Isn't the count specified from rows=XXX? > Allow default sort order > ------------------------ > > Key: SOLR-99 > URL: https://issues.apache.org/jira/browse/SOLR-99 > Project: Solr > Issue Type: Improvement > Components: search > Affects Versions: 1.2 > Reporter: Ryan McKinley > Priority: Minor > Fix For: 1.2 > > Attachments: DefaultSortOrder.patch, DefaultSortOrder.patch > > > 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 ) { > + str=parts[pos]; > + if ("bottom".equals(str) || "asc".equals(str)) { > + top=false; > + } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira