Thanks Sean for the hint over "pre-sort" feature. Didn't knew about this 
feature and looks like it is missing from riak search docs too.
Looks like we have some sanity restored by changing the way we generate our doc 
ids such that "presort=key" makes sense for us.

Regards,
--
Abhinav Singh
http://abhinavsingh.com/

On 04-Dec-2012, at 8:22 PM, Sean Cribbs <[email protected]> wrote:

> Abhinav,
> 
> What you are running into is a limitation of Riak Search. For some 
> perhaps-forgotten reason, sorting is done *after* limiting, which ends up 
> returning unexpected results in some cases. However, you can presort the 
> results by key using the "presort" query parameter, assuming that ordering 
> makes sense.
> 
> This limitation of Riak Search, and many others, is addressed by Ryan 
> Zezeski's Yokozuna. You can watch him talk about it here: 
> http://vimeo.com/54266574
> 
> 
> On Tue, Dec 4, 2012 at 7:58 AM, Abhinav Singh <[email protected]> wrote:
> Hello Everyone,
> 
> I have been developing an application using riak search.
> I have `riak-1.2.1rc2` installed on my local dev box and most of the things 
> works as expected on my local dev,
> except for offset problem while using `start=N&rows=M` in riak search 
> queries, as shown below:
> 
> NOTE: This problem persists when I move the application to our production 
> environment setup which uses riak-1.2.1 stable release.
> 
> 1) /select?start=0&rows=28&sort=ts_num 
> asc&wt=json&q=to:71ad5c26855312ad414caa60c841d48e9a92af1e
> 
> Returns me docs with id in following order (I have added ts_num field info 
> for ordering reference):
> 
> "5998c1fe483ff4e5289542ea7a9b7eabb8265fbc"          1354624548
> "011a4a8c3caccaa61e6d7568dcac5c2b994b3b42"      1354626378
> "ffc9b15ea3756b31ea56298e87c4083a1f49080f"          1354626493
> "5eed8e6f9a3a804b3c3ae05d32f0bc2b09bdd44f"         1354626724
> "657c38f5832a6f421465093edf93e1b5597891a1"         1354626724
> …
> …
> 
> 2) /select?start=1&rows=28&sort=ts_num 
> asc&wt=json&q=to:71ad5c26855312ad414caa60c841d48e9a92af1e
> 
> "5998c1fe483ff4e5289542ea7a9b7eabb8265fbc"           1354624548       <--- I 
> wasn't really expecting this doc id to be returned, infact doc id 
> "011a4a8c3caccaa61e6d7568dcac5c2b994b3b42" from above result set is gone 
> missing
> "ffc9b15ea3756b31ea56298e87c4083a1f49080f"           1354626493
> "5eed8e6f9a3a804b3c3ae05d32f0bc2b09bdd44f"          1354626724
> "657c38f5832a6f421465093edf93e1b5597891a1"          1354626724
> "aace68ad8eb490e2a7053482c403b18b18567190"      1354626724
> …
> …
> 
> 3) /select?start=0&rows=5&sort=ts_num 
> asc&wt=json&q=to:71ad5c26855312ad414caa60c841d48e9a92af1e
> 
> "011a4a8c3caccaa61e6d7568dcac5c2b994b3b42"     1354626378        <---- 
> starting with doc id "011a4a8c3caccaa61e6d7568dcac5c2b994b3b42", while I was 
> expecting "5998c1fe483ff4e5289542ea7a9b7eabb8265fbc" as the first item
> "02c790e1e15e82166c91eee37ec1dfd8a1f0b588"      1354626755        <---- doc 
> ids from here on are picked from entirely unexpected offset
> "0739a91ec35495be32e55deb7fe859b4ea7734e9"    1354626755
> "101dc3d3cf005802b8c89efb05e11556535c5ff6"         1354626755
> "2224778981d100fb30709e0127fe1a7640ef68ae"      1354626755
> 
> 4) /select?start=1&rows=5&sort=ts_num 
> asc&wt=json&q=to:71ad5c26855312ad414caa60c841d48e9a92af1e
> 
> "02c790e1e15e82166c91eee37ec1dfd8a1f0b588"       1354626755      <---- 
> ordering of results look fine but I was expecting them to start from 
> "011a4a8c3caccaa61e6d7568dcac5c2b994b3b42" i.e. results are returned from an 
> unexpected offset
> "0739a91ec35495be32e55deb7fe859b4ea7734e9"     1354626755
> "101dc3d3cf005802b8c89efb05e11556535c5ff6"          1354626755
> "2224778981d100fb30709e0127fe1a7640ef68ae"       1354626755
> "346bf1800c904c811a8ac5eca195462a5829cbd8"      1354626755
> 
> Is there a problem with my understanding of riak search? or is this a known 
> bug?
> Feedback and help is greatly appreciated.
> Thanks in advance.
> 
> --
> Abhinav
> 
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> 
> 
> -- 
> Sean Cribbs <[email protected]>
> Software Engineer
> Basho Technologies, Inc.
> http://basho.com/
> 

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to