#109 ✓resolved
yipdw

[PATCH] Revert automatic range sorting

Reported by yipdw | April 12th, 2010 @ 03:55 PM

Description

The patch is a partial revert of 91336cdf2e55bab689f5c6533fdd5766f7daa5af.

Rationale

I think this is an issue that is better handled by the application developer, not Sunspot. If a range r is provided for which r.first > r.last, it is an issue, but it is an issue which can (and should) be handled by the application developer. Some examples:

The application developer screwed up range construction. In this case, there is an error lurking in the application code, and Sunspot should not mask this error.


The application developer is using user input in range construction, the user entered in values for first and last such that first > last, and the application neither checks that first < last holds nor handles Solr exceptions. This, again, is an error lurking in the application code, and Sunspot should not mask this error.


The application developer wants to use ranges merely for their syntax, not their semantics. (Sunspot's between scope already seems to this in the sense that it doesn't even require a Range object.) Given that, the below is something that arguably makes sense:

with(:key).between('9'..'11')

Strings are natural candidates for range boundaries if working with user input. ('9'..'11') is an empty range, but still has what one would expect for first and last. However, because '9' > '11' by lexicographical ordering, Sunspot will turn this into something like

fq=key_i:[11 TO 9]

when, without sorting, it would generate the expected

fq=key_i:[9 TO 11]

This is, admittedly, at odds with scenario 2: if you need a min and max, you should be checking that, and that involves type coercion. However, the point of this scenario is to demonstrate that Sunspot doesn't need to worry about the nature of the range it's given.

Comments and changes to this ticket

  • mat

    mat June 29th, 2010 @ 05:19 PM

    • State changed from “new” to “resolved”
    • Milestone order changed from “0” to “0”

    (from [c38a7bd72f75f5d0dc3f2aaa61241e1a3d8838c6]) Eliminated value sorting for range scopes.

    Rationale:

    I think this is an issue that is better handled by the application
    developer, not Sunspot. If a range r is provided for which r.first >
    r.last, it is an issue, but it can (it should!) be solved by the
    application developer. Some examples:

    • The application developer screwed up range construction. In this case, there is an error lurking in the application code, and Sunspot should not mask this error.
    • The application developer is using user input in range construction, the user entered in values for first and last such that first > last, and the application does not check that first < last is true. This, again, is an error lurking in the application code, and Sunspot should not mask this error.
    • The application developer wants to use ranges merely for their syntax, not their semantics. (Sunspot's between scope already does this in the sense that it uses ranges merely as a convenient value container.) Given that, the below is something that makes sense to do:

      with(:key).between('9'..'11')

    However, because '9' > '11' by lexicographical ordering, Sunspot will turn this into something like

    fq=key_i:[11 TO 9]
    

    when, without sorting, it would generate the expected

    fq=key_i:[9 TO 11]
    

    The only way to currently solve this is to coerce those strings to an appropriate numeric type, which seems unnecessary, since these queries work fine with string inputs.

    [#109 state:resolved] http://github.com/outoftime/sunspot/commit/c38a7bd72f75f5d0dc3f2aaa...

  • mat
  • mat

    mat December 1st, 2011 @ 12:22 PM

    (from [604d6a8c2bed8b933879d8f4cb94734b791168b4]) Merge branch 'gh-pages' of github.com:sunspot/sunspot into gh-pages

    • 'gh-pages' of github.com:sunspot/sunspot: [Fixes #109] Adds word boundary requirement after a/an/the Updates docs Adds Google Analytics Freshen up the landing page Normalizes whitespace Replaces outoftime links with sunspot repo

    Conflicts:

    index.html
    

    https://github.com/sunspot/sunspot/commit/604d6a8c2bed8b933879d8f4c...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Awesome Solr interaction for Ruby

People watching this ticket

Referenced by

Pages