Fredrik,

Unfortunately, because of limitations in Riak Search 0.14.x, it can only
(pre-)sort reliably on the document ID.  However, it seems like OrderNumber
might be a natural ID for this document?  If so, you could do something like
the following:

http://riak/solr/order/select?rows=1&presort=key&q=
Order_Contact_Email:[email protected]

However, this query will also return in ascending order.  If you just want
the highest order number, then feeding this query to MapReduce and
processing it there would seem appropriate.

2011/9/12 Fredrik Lindström <[email protected]>

>  Hi everyone,
> does the "sort=myfieldname desc" parameter in riaksearch 0.14.2 (via solr)
> only sort within the current result set dictated by rows=x and start =y?
>
> I can get my search results in the correct ASC order regardless of the rows
> and start parameters.
> Sorting in DESC with rows=1 and start=0 I get one (obviously) result but
> the result actually appears to be in ASC order. The doc returned in the
> search result is the one with the lowest integer value in the field used for
> sorting.
>
> I'm quite new to Riak and Riak Search and therefore I assume that the error
> is on my part.
>
> Some technical details:
>
> Total objects in "order" bucket: 187
>
> Query with DESC sort:
>
> http://riak/solr/order/select?rows=1&start=0&sort=Order_OrderNumber%20desc&q=Order_Contact_Email:[email protected]
> Result: 1 doc with Order_OrderNumber = 362982 (Expected result in my world
> of fantasy would be 621738 which is currently the highest value)
>
> Query with ASC sort:
>
> http://riak/solr/order/select?rows=1&start=0&sort=Order_OrderNumber%20asc&q=Order_Contact_Email:[email protected]<http://riak/solr/order/select?rows=1&start=0&sort=Order_OrderNumber%20desc&q=Order_Contact_Email:[email protected]>
> Result: 1 doc with Order_OrderNumber = 362982
>
> I have a custom schema where I have defined the field I want to sort by in
> the following way:
>         {field, [
>             {name, "Order_OrderNumber"},
>             {type, integer},
>             {analyzer_factory, {erlang, text_analyzers,
> integer_analyzer_factory}}
>         ]},
>
> If I run the DESC query with rows=187 the results are ordered in the
> correct descending order.
>
> /F
>
>
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>


-- 
Sean Cribbs <[email protected]>
Developer Advocate
Basho Technologies, Inc.
http://www.basho.com/
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to