[ 
https://issues.apache.org/jira/browse/SOLR-10016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Timothy Potter updated SOLR-10016:
----------------------------------
    Attachment: SOLR-10016.patch

Here's a patch (-p0 style) prepared against branch_6_5 that adds the ability to 
sort SQL query results using Solr's random_SEED trick (via RandomStream).

To use this, your SQL would look something like:
{code}
curl --data-urlencode "stmt=select movie_id, user_id from ratings order by 
_random_ asc limit 100" "http://localhost:8983/solr/ratings/sql";
{code}

Unlike with score, the _random_ sort field doesn't need to be included in the 
results, which I felt was unnecessary since it's just a random number.

Still needs a test but wanted to post something up to get initial feedback.

Ideally, we'd be able to sort by any ValueSource as well as include the value 
of a ValueSource in the results. However, it seems like we need to expose the 
name and type of every possible ValueSource in the SolrSchema.getRelDataType 
return value? [~joel.bernstein] or [~risdenk] any suggestions on the best way 
to support any ValueSource in a SQL query? Seems like that would force the user 
to have to use LIMIT afaik, ValueSource's aren't exportable. Also, let me know 
if this approach is acceptable for random sorting.

> SQL should support sorting by random_<SEED>
> -------------------------------------------
>
>                 Key: SOLR-10016
>                 URL: https://issues.apache.org/jira/browse/SOLR-10016
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: Parallel SQL
>            Reporter: Timothy Potter
>            Assignee: Timothy Potter
>         Attachments: SOLR-10016.patch
>
>
> I tried using the handy sort=random_<SEED> feature in normal queries with SQL 
> and it failed:
> {code} 
> curl --data-urlencode "stmt=select rating, movie_id, user_id from ratings 
> order by random_5150 asc" \
> >  "http://localhost:8983/solr/ratings/sql";
> {"result-set":{"docs":[
> {"EXCEPTION":"Fields in the sort spec must be included in the field 
> list:random_5150","EOF":true}]}}
> {code}
> I'd like to take a stab at fixing this if there are no objections to me doing 
> so?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to