Hi Sean,
thank you for the clarification. In our scenario a user might have many orders 
so it would be nice to be able to page through the result set in descending 
order.
Since our OrderNumbers are guaranteed to be unique we are currently using them 
as the keys in Riak. They numbers are also created sequentially, hence the 
desire to page through them in descending order giving the user a chronological 
perspective of placed orders.

We're still quite early in the process of evaluating Riak for our project so we 
have plenty of time to try other approaches.

/F
________________________________
From: Sean Cribbs [[email protected]]
Sent: Monday, September 12, 2011 3:53 PM
To: Fredrik Lindström
Cc: [email protected]
Subject: Re: riaksearch 0.14.2 via solr: sort desc

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]<mailto: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]<mailto:[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]<mailto:[email protected]>
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com




--
Sean Cribbs <[email protected]<mailto:[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