8

trying to figure out whether this is a bug or by design. when no query_string is specified for a query, the SearchResults object is NOT sorted by the requested column. for example, here is some logging to show the problem:

Results are returned unsorted on return index.search(query):

query_string = ''

sort_options string: search.SortOptions(expressions=[search.SortExpression(expression=u'firstname', direction='ASCENDING', default_value=u'')], limit=36)

Results are returned sorted on return index.search(query):

query_string = 'test'

sort_options string: search.SortOptions(expressions=[search.SortExpression(expression=u'firstname', direction='ASCENDING', default_value=u'')], limit=36)

This is how I'm constructing my query for both cases (options has limit, offset and sort_options parameters):

query = search.Query(query_string=query_string, options=options)

HorseloverFat
  • 3,290
  • 5
  • 22
  • 32
  • 1
    did you read this already? http://code.google.com/p/googleappengine/issues/detail?id=7456&q=index%20direction&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log (just out of curiosity, since in the example he's got an empty search query too) – Samuele Mattiuzzo Dec 19 '12 at 15:46
  • thanks for pointing me towards that. seems like it's a bug with the dev_server. feel free to make this an answer. – HorseloverFat Dec 19 '12 at 15:49
  • 1
    done, but test it online before being sure it's a bug or not – Samuele Mattiuzzo Dec 19 '12 at 15:52

2 Answers2

1

This may be a bug of the dev_appserver, as suggested here but to be sure, you should test your application on your appspot

Samuele Mattiuzzo
  • 10,760
  • 5
  • 39
  • 63
-2

Could be a bug in the way you build your query, since it's not shown.

Could be that you don't have an index for the case that isn't working.

dragonx
  • 14,963
  • 27
  • 44
  • 1) The query is built in the same way for both cases, and in one case the results are sorted, and in the other they aren't. So this seems to exclude that possibility. – HorseloverFat Dec 19 '12 at 15:35
  • 2) The same index is being used for both cases so that is not the root cause. – HorseloverFat Dec 19 '12 at 15:36