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 anuragwalia <an...@gmail.com> on 2013/12/05 07:59:17 UTC

Sorting on solr results

HI All,

Please provide me your idea for below problem.

I required to sort product on webshop price with position.

e.g. If we have three product (A, B ,C) needs to sort Price asc and position
asc.

ID	Price	Position
A	10	3
B	10	2
C	20	5

Result should be sorted forst by price than by position.

Required Order of result :
B
A
C
While A,B products having same price but position of B is higher then A.
My result set query as of now
:&@QueryTerm=*&OnlineFlag=1&@Sort.Price=0,position=0

Please suggest your views for the same.

 





--
View this message in context: http://lucene.472066.n3.nabble.com/Sorting-on-solr-results-tp4105060.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Sorting on solr results

Posted by Erick Erickson <er...@gmail.com>.
Isn't this just
sort=Price asc, Position asc
?

But I agree with Shawn, I have no clue what
:&@QueryTerm=*&OnlineFlag=1&@Sort.Price=0,position=0
is all about. Possibly a front end to Solr that has its
own query language? In which case you'd have to talk
to whoever maintains that....

Best,
Erick


On Thu, Dec 5, 2013 at 10:05 AM, Shawn Heisey <so...@elyograg.org> wrote:

> On 12/4/2013 11:59 PM, anuragwalia wrote:
> > I required to sort product on webshop price with position.
> >
> > e.g. If we have three product (A, B ,C) needs to sort Price asc and
> position
> > asc.
> >
> > ID    Price   Position
> > A     10      3
> > B     10      2
> > C     20      5
> >
> > Result should be sorted forst by price than by position.
> >
> > Required Order of result :
> > B
> > A
> > C
> > While A,B products having same price but position of B is higher then A.
> > My result set query as of now
> > :&@QueryTerm=*&OnlineFlag=1&@Sort.Price=0,position=0
>
> These are not Solr parameters.  If you have a solr boolean field named
> OnlineFlag and you want to match all documents with OnlineFlag set and
> sort as you mentioned, this is the URL and parameter string you need on
> a typical Solr install:
>
> http://server:port
> /corename/solr/select?q=*:*&fq=OnlineFlag:true&sort=Price+asc,Position+asc
>
> If OnlineFlag is a numeric field (int/long or a variant) rather than
> boolean, you can include the following in the parameter list instead:
>
> &fq=OnlineFlag:1
>
> Wiki page covering the parameters that I have used and a few more:
>
> http://wiki.apache.org/solr/CommonQueryParameters
>
> Thanks,
> Shawn
>
>

Re: Sorting on solr results

Posted by Shawn Heisey <so...@elyograg.org>.
On 12/4/2013 11:59 PM, anuragwalia wrote:
> I required to sort product on webshop price with position.
> 
> e.g. If we have three product (A, B ,C) needs to sort Price asc and position
> asc.
> 
> ID	Price	Position
> A	10	3
> B	10	2
> C	20	5
> 
> Result should be sorted forst by price than by position.
> 
> Required Order of result :
> B
> A
> C
> While A,B products having same price but position of B is higher then A.
> My result set query as of now
> :&@QueryTerm=*&OnlineFlag=1&@Sort.Price=0,position=0

These are not Solr parameters.  If you have a solr boolean field named
OnlineFlag and you want to match all documents with OnlineFlag set and
sort as you mentioned, this is the URL and parameter string you need on
a typical Solr install:

http://server:port/corename/solr/select?q=*:*&fq=OnlineFlag:true&sort=Price+asc,Position+asc

If OnlineFlag is a numeric field (int/long or a variant) rather than
boolean, you can include the following in the parameter list instead:

&fq=OnlineFlag:1

Wiki page covering the parameters that I have used and a few more:

http://wiki.apache.org/solr/CommonQueryParameters

Thanks,
Shawn