You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by James Lin <gu...@gmail.com> on 2011/03/16 03:41:08 UTC

noobie question: sorting

Hi Guys,

came across this sorting query

query ({!v="category: 445"}) desc

I understand it is sorting on exact match of category = 445, I don't quite
understand the syntax, could someone please elaborate a bit for me? So I can
reuse this syntax in the future.

Regards

James

Re: noobie question: sorting

Posted by James Lin <gu...@gmail.com>.
AWESOME, thanks for your time!

Regards

James

On Wed, Mar 16, 2011 at 6:14 PM, David Smiley (@MITRE.org) <
DSMILEY@mitre.org> wrote:

> Hi.  Where did you find such an obtuse example?
>
> Recently, Solr supports sorting by function query.  One such function is
> named "query" which takes a query and uses the score of the result of that
> query as the function's result.  Due to constraints of where this query is
> placed within a function query, it is necessary to use the local-params
> syntax (e.g. {!v=...}) since you can't simply state "category:445".  Or,
> there could have been a parameter dereference like $sortQ where sortQ is
> another parameter holding category:445.  Any way, the net effect is that
> documents are score-sorted based on the query category:445 instead of the
> user-query ("q" param). I'd expect category:445 docs to come up top and all
> others to appear randomly afterwards.  It would be nice if the sort query
> could simply be "category:445 desc" but that's not supported.
>
> Complicated?  You bet!  But fear not; this is about as complicated as it
> gets.
>
> References:
> http://wiki.apache.org/solr/SolrQuerySyntax
> http://wiki.apache.org/solr/CommonQueryParameters#sort
> http://wiki.apache.org/solr/FunctionQuery#query
>
> ~ David Smiley
>  Author: https://www.packtpub.com/solr-1-4-enterprise-search-server/book
>
> -----
>  Author: https://www.packtpub.com/solr-1-4-enterprise-search-server/book
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/noobie-question-sorting-tp2685250p2685617.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: noobie question: sorting

Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
Hi.  Where did you find such an obtuse example?

Recently, Solr supports sorting by function query.  One such function is
named "query" which takes a query and uses the score of the result of that
query as the function's result.  Due to constraints of where this query is
placed within a function query, it is necessary to use the local-params
syntax (e.g. {!v=...}) since you can't simply state "category:445".  Or,
there could have been a parameter dereference like $sortQ where sortQ is
another parameter holding category:445.  Any way, the net effect is that
documents are score-sorted based on the query category:445 instead of the
user-query ("q" param). I'd expect category:445 docs to come up top and all
others to appear randomly afterwards.  It would be nice if the sort query
could simply be "category:445 desc" but that's not supported.

Complicated?  You bet!  But fear not; this is about as complicated as it
gets.

References:
http://wiki.apache.org/solr/SolrQuerySyntax
http://wiki.apache.org/solr/CommonQueryParameters#sort
http://wiki.apache.org/solr/FunctionQuery#query

~ David Smiley
 Author: https://www.packtpub.com/solr-1-4-enterprise-search-server/book

-----
 Author: https://www.packtpub.com/solr-1-4-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/noobie-question-sorting-tp2685250p2685617.html
Sent from the Solr - User mailing list archive at Nabble.com.