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 "Sowmya V.B." <vb...@gmail.com> on 2011/08/22 09:56:33 UTC

Sorting results by Range

Dear All

I have been searching on how to sort Solr results based on a range
query..but did not find decipherable answers. Hence, mailing again. Sorry if
the query was already posed -i was not able to find it.

I want to add an option to sort the results, based on a field range chosen.
(For eg: "Sort Results based on the Field A, being from 20 to 30", "Sort in
such a way that the date field points to dates between August 1st to 10th"
etc)

I don't want to Filter the results. I just wanted all the results, along
with an option to sort the results, if the user wants it.

Is there anything in Solr, the allows me sort by range?

I Tried giving something like this, following the Sort-without-range
specification syntax, and needless to say, it threw me syntax error.
http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sort=Field1:[20TO
30] asc

http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sortBy=Field1:[20TO
30] asc
-Does not throw a Syntax error,  but does not seem to work anyways.

Thanks for the help!

Sowmya.

-- 
Sowmya V.B.
----------------------------------------------------
Losing optimism is blasphemy!
http://vbsowmya.wordpress.com
----------------------------------------------------

Re: Sorting results by Range

Posted by "Sowmya V.B." <vb...@gmail.com>.
Hi Chris

I understood how to handle this now.
I tried and I am getting what I wanted.

Thanks for a very detailed explanation. I reversed the asc, desc part and
was wondering that its not working as I wanted. After seeing the latest
mail, I figured out my mistake.

Thanks once again!

On Fri, Sep 2, 2011 at 1:12 AM, Chris Hostetter <ho...@fucit.org>wrote:

>
> : sort=map(map(myNumField,0,10,0),20,100,0) desc, score desc
> : sort=map(map(myNumField,0,10,100),20,100,100) asc, score desc
>        ...
> : By doing the second one, I expected to get the same results, ordered like
> : 13, 17,18, 20. But, what I got were other values as results, that are not
> in
> : the chosen range: 9, 8,7, 5 etc.
> :
> : My question previously was: How to get results with "myNumFields" values
> : between 10 and 20 ranked above the rest, in the ascending order.
>
> Hmmm.... w/o more info i'm not sure that i can explain the behavior you
> are seeing.
>
> Using the 3x branch, with the 17 example docs indexed, i just tried these
> queries...
>
>
> http://localhost:8983/solr/select?q=*:*+video+solr&fl=score,popularity&rows=100&sort=score+desc
>
> ...returns all 17 docs, ordered by score descending, and shows that all
> the popularity values are between 0 and 10.
>
>
> http://localhost:8983/solr/select?q=*:*+video+solr&fl=score,popularity&rows=100&sort=map%28map%28popularity,0,5,0%29,8,10,0%29+desc,+score+desc
>
> ...reorders the docs so everything with a popularity value above 5 and
> less then 8 is listed first, descending (ie: pop sevens then pop sixes),
> followed by all other docs in order of score descending (regardless of the
> popularity value)
>
>
> http://localhost:8983/solr/select?q=*:*+video+solr&fl=score,popularity&rows=100&sort=map%28map%28popularity,0,5,100%29,8,10,100%29+asc,+score+desc
>
> ...reorders the docs so everything with a popularity value above 5 and
> less then 8 is listed first, ascending (ie: pop sixes then pop sevents),
> followed by all other docs in order of score descending (regardless of the
> popularity value)
>
> perhaps you could post your configs and some sample data in an easy to
> consume format (csv?) demonstrating the problem you are seeing?
>
> -Hoss
>



-- 
Sowmya V.B.
----------------------------------------------------
Losing optimism is blasphemy!
http://vbsowmya.wordpress.com
----------------------------------------------------

Re: Sorting results by Range

Posted by Chris Hostetter <ho...@fucit.org>.
: sort=map(map(myNumField,0,10,0),20,100,0) desc, score desc
: sort=map(map(myNumField,0,10,100),20,100,100) asc, score desc
	...
: By doing the second one, I expected to get the same results, ordered like
: 13, 17,18, 20. But, what I got were other values as results, that are not in
: the chosen range: 9, 8,7, 5 etc.
: 
: My question previously was: How to get results with "myNumFields" values
: between 10 and 20 ranked above the rest, in the ascending order.

Hmmm.... w/o more info i'm not sure that i can explain the behavior you 
are seeing.

Using the 3x branch, with the 17 example docs indexed, i just tried these 
queries...

http://localhost:8983/solr/select?q=*:*+video+solr&fl=score,popularity&rows=100&sort=score+desc

...returns all 17 docs, ordered by score descending, and shows that all 
the popularity values are between 0 and 10.

http://localhost:8983/solr/select?q=*:*+video+solr&fl=score,popularity&rows=100&sort=map%28map%28popularity,0,5,0%29,8,10,0%29+desc,+score+desc

...reorders the docs so everything with a popularity value above 5 and 
less then 8 is listed first, descending (ie: pop sevens then pop sixes), 
followed by all other docs in order of score descending (regardless of the 
popularity value) 

http://localhost:8983/solr/select?q=*:*+video+solr&fl=score,popularity&rows=100&sort=map%28map%28popularity,0,5,100%29,8,10,100%29+asc,+score+desc

...reorders the docs so everything with a popularity value above 5 and 
less then 8 is listed first, ascending (ie: pop sixes then pop sevents), 
followed by all other docs in order of score descending (regardless of the 
popularity value) 

perhaps you could post your configs and some sample data in an easy to 
consume format (csv?) demonstrating the problem you are seeing?

-Hoss

Re: Sorting results by Range

Posted by "Sowmya V.B." <vb...@gmail.com>.
Hi Chris

Thanks for the clarification.

My Doubt:* You said:
so if the range of legal values is 0-100, and you care about 10-20

sort=map(map(myNumField,0,10,0),20,100,0) desc, score desc
sort=map(map(myNumField,0,10,100),20,100,100) asc, score desc
*
By doing the first one, I got results with "myNumField" values between 10
and 20 ranked above all, in the descending order - 20, 18, 17, 13 etc.

By doing the second one, I expected to get the same results, ordered like
13, 17,18, 20. But, what I got were other values as results, that are not in
the chosen range: 9, 8,7, 5 etc.

My question previously was: How to get results with "myNumFields" values
between 10 and 20 ranked above the rest, in the ascending order.

Regards
Sowmya.
On Tue, Aug 23, 2011 at 7:48 PM, Chris Hostetter
<ho...@fucit.org>wrote:

>
> : I did not quite understand how that function was made. But, it does work
>
> basically the "map" function just translates values in a ranage to some
> fixed vald value.  so if you nest two map functions (that use
> different ranges) inside of eachother you get a resulting curve that is
> flat in those two ranges (below 10 and above 20) and returns the actual
> field value in the middle.
>
> : (I chose a field with 0 and 100 as limits and tried with that. So,
> replaced
> : infinities with 0 and 100 respectively)
> :
> : sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) desc, score desc
> :
> : If I needed Sorted results in ascending order, Results around the value
> 10
> : ranked above those of 20, what should I do in this case?
> :
> : I tried giving,
> : sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) *asc*, score desc
> : But, that does not seem to work quite as I expected.
>
> Hmmm... ok.  FWIW: anytime you say things like "does not seem to work
> quite as I expected" ... you really need to explain: a) what you expected.
> b) what you got.
>
> But i think i see the problem...
>
> if you change to asc, then it's going to sort docs by the result of that
> function asc, and because of the map a *lot* of docs are going to have a
> value of "0" for that function -- so in addition to changing to "asc"
> you'll want to change the target value of that function to something above
> the upper endpoint of the range you care about (20 in this example)
>
> so if the range of legal values is 0-100, and you care about 10-20
>
> sort=map(map(myNumField,0,10,0),20,100,0) desc, score desc
> sort=map(map(myNumField,0,10,100),20,100,100) asc, score desc
>
>
>
> -Hoss
>



-- 
Sowmya V.B.
----------------------------------------------------
Losing optimism is blasphemy!
http://vbsowmya.wordpress.com
----------------------------------------------------

Re: Sorting results by Range

Posted by Chris Hostetter <ho...@fucit.org>.
: I did not quite understand how that function was made. But, it does work

basically the "map" function just translates values in a ranage to some 
fixed vald value.  so if you nest two map functions (that use 
different ranges) inside of eachother you get a resulting curve that is 
flat in those two ranges (below 10 and above 20) and returns the actual 
field value in the middle.

: (I chose a field with 0 and 100 as limits and tried with that. So, replaced
: infinities with 0 and 100 respectively)
: 
: sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) desc, score desc
: 
: If I needed Sorted results in ascending order, Results around the value 10
: ranked above those of 20, what should I do in this case?
: 
: I tried giving,
: sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) *asc*, score desc
: But, that does not seem to work quite as I expected.

Hmmm... ok.  FWIW: anytime you say things like "does not seem to work 
quite as I expected" ... you really need to explain: a) what you expected. 
b) what you got.

But i think i see the problem...

if you change to asc, then it's going to sort docs by the result of that 
function asc, and because of the map a *lot* of docs are going to have a 
value of "0" for that function -- so in addition to changing to "asc" 
you'll want to change the target value of that function to something above 
the upper endpoint of the range you care about (20 in this example)

so if the range of legal values is 0-100, and you care about 10-20

sort=map(map(myNumField,0,10,0),20,100,0) desc, score desc
sort=map(map(myNumField,0,10,100),20,100,100) asc, score desc



-Hoss

Re: Sorting results by Range

Posted by "Sowmya V.B." <vb...@gmail.com>.
Hi Chris

Thanks a lot for the mail.

I did not quite understand how that function was made. But, it does work
like you said - there is a sorted list of documents now, where documents
around value 20 are ranked first and documents around 10 are ranked below.
(I chose a field with 0 and 100 as limits and tried with that. So, replaced
infinities with 0 and 100 respectively)

sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) desc, score desc

If I needed Sorted results in ascending order, Results around the value 10
ranked above those of 20, what should I do in this case?

I tried giving,
sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) *asc*, score desc
But, that does not seem to work quite as I expected.

S.


On Mon, Aug 22, 2011 at 9:48 PM, Chris Hostetter
<ho...@fucit.org>wrote:

>
> : 1) The user gives a query, and also has an option to choose the "from"
> and
> : "to" values for a specific field.
> : (For Eg: Give me all documents that match the query Solr Users, but with
> : those that were last updated between 10th and 20th of August ranked on
> top)
> :
> : -Over here, I am currently using a BoostQuery functionality, to do this.
> : However, along with this, I want to provide an additional option of
> Sorting
> : these "boosted" results based on that range chosen above.
>
> This should be doable using sort by function, but obviously you'd have to
> decide which "end" of the range should score higher.
>
> the key would be to:
>  * use a primary and a secondary sort
>  * secondary sort is simple "score desc"
>  * primary sort is on a function over the field whose range you care about
>  * primary sort function needs to map all values out of the range to a
> constant value so secondary sort applies.
>
> I haven't tested this out, but i think the "map" function should make this
> relatively straight forward...
>
> sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) desc, score desc
>
> Assuming "-Infinity" and "Infinity" are actaully legal values in functions
> (if they aren't you'd need to pick some upper/lower limits) that should
> sort any doc where "myNumField" is between 10 and 20 first, with docs
> matching "20" sorting at the top above docs matching "19, 18, ... 10" and
> then after those docs all remaining matching docs will sort by score.
>
>
> -Hoss
>



-- 
Sowmya V.B.
----------------------------------------------------
Losing optimism is blasphemy!
http://vbsowmya.wordpress.com
----------------------------------------------------

Re: Sorting results by Range

Posted by Chris Hostetter <ho...@fucit.org>.
: 1) The user gives a query, and also has an option to choose the "from" and
: "to" values for a specific field.
: (For Eg: Give me all documents that match the query Solr Users, but with
: those that were last updated between 10th and 20th of August ranked on top)
: 
: -Over here, I am currently using a BoostQuery functionality, to do this.
: However, along with this, I want to provide an additional option of Sorting
: these "boosted" results based on that range chosen above.

This should be doable using sort by function, but obviously you'd have to 
decide which "end" of the range should score higher.

the key would be to:
 * use a primary and a secondary sort
 * secondary sort is simple "score desc"
 * primary sort is on a function over the field whose range you care about
 * primary sort function needs to map all values out of the range to a 
constant value so secondary sort applies.

I haven't tested this out, but i think the "map" function should make this 
relatively straight forward... 

sort=map(map(myNumField,-Infinity,10,0),20,Infinity,0) desc, score desc
  
Assuming "-Infinity" and "Infinity" are actaully legal values in functions 
(if they aren't you'd need to pick some upper/lower limits) that should 
sort any doc where "myNumField" is between 10 and 20 first, with docs 
matching "20" sorting at the top above docs matching "19, 18, ... 10" and 
then after those docs all remaining matching docs will sort by score.


-Hoss

Re: Sorting results by Range

Posted by "Sowmya V.B." <vb...@gmail.com>.
Thanks for the clarification Erick!

On Mon, Aug 22, 2011 at 4:30 PM, Erick Erickson <er...@gmail.com>wrote:

> OK, I think I get it now. There's nothing in Solr that I know of that'll
> let you
> do this. Although you could add a clause boosted insanely high, something
> like date_modified:[aug10 TO aug 20]^10000 that would bubble your target
> results toward the top of your list... Note, that's not the correct
> date syntax...
>
> You'd probably have to have your app do the fine-grained sorting, that
> is of the,
> say, 20 docs returned in your list, sort them by your aug10-20 dates.
>
> Best
> Erick
>
> On Mon, Aug 22, 2011 at 10:07 AM, Sowmya V.B. <vb...@gmail.com> wrote:
> > Hi Eric
> >
> > Let me clarify:
> >
> > 1) The user gives a query, and also has an option to choose the "from"
> and
> > "to" values for a specific field.
> > (For Eg: Give me all documents that match the query Solr Users, but with
> > those that were last updated between 10th and 20th of August ranked on
> top)
> >
> > -Over here, I am currently using a BoostQuery functionality, to do this.
> > However, along with this, I want to provide an additional option of
> Sorting
> > these "boosted" results based on that range chosen above.
> >
> > 2) I don't want to use an Fq option because, it will filter out the
> > documents not within this range. I want the all the results relevant to
> the
> > query, with an option to put a sorted list of documents, that satisfy the
> > range requirements.
> >
> > I hope I made my query clearer now.
> >
> > S.
> >
> > On Mon, Aug 22, 2011 at 4:01 PM, Erick Erickson <erickerickson@gmail.com
> >wrote:
> >
> >> I guess I'm having trouble understanding this. "I just wanted all the
> >> results,
> >> along with an option to sort the results, if the user wants it."
> >>
> >> What does "all the results" mean? The results you would have had if it
> >> you didn't have a sort? There's no way to guarantee that the results
> >> returned
> >> by relevance contain the range you want, unless you really
> >> do return all the results, possibly thousands to millions of documents.
> >>
> >>
> >> If you used an fq clause, the app could sort the results without
> executing
> >> another search if you wanted to sort them by date...
> >>
> >> Best
> >> Erick
> >>
> >>
> >> On Mon, Aug 22, 2011 at 3:56 AM, Sowmya V.B. <vb...@gmail.com>
> wrote:
> >> > Dear All
> >> >
> >> > I have been searching on how to sort Solr results based on a range
> >> > query..but did not find decipherable answers. Hence, mailing again.
> Sorry
> >> if
> >> > the query was already posed -i was not able to find it.
> >> >
> >> > I want to add an option to sort the results, based on a field range
> >> chosen.
> >> > (For eg: "Sort Results based on the Field A, being from 20 to 30",
> "Sort
> >> in
> >> > such a way that the date field points to dates between August 1st to
> >> 10th"
> >> > etc)
> >> >
> >> > I don't want to Filter the results. I just wanted all the results,
> along
> >> > with an option to sort the results, if the user wants it.
> >> >
> >> > Is there anything in Solr, the allows me sort by range?
> >> >
> >> > I Tried giving something like this, following the Sort-without-range
> >> > specification syntax, and needless to say, it threw me syntax error.
> >> >
> >>
> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sort=Field1:[20TO
> >> > 30] asc
> >> >
> >> >
> >>
> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sortBy=Field1:[20TO
> >> > 30] asc
> >> > -Does not throw a Syntax error,  but does not seem to work anyways.
> >> >
> >> > Thanks for the help!
> >> >
> >> > Sowmya.
> >> >
> >> > --
> >> > Sowmya V.B.
> >> > ----------------------------------------------------
> >> > Losing optimism is blasphemy!
> >> > http://vbsowmya.wordpress.com
> >> > ----------------------------------------------------
> >> >
> >>
> >
> >
> >
> > --
> > Sowmya V.B.
> > ----------------------------------------------------
> > Losing optimism is blasphemy!
> > http://vbsowmya.wordpress.com
> > ----------------------------------------------------
> >
>



-- 
Sowmya V.B.
----------------------------------------------------
Losing optimism is blasphemy!
http://vbsowmya.wordpress.com
----------------------------------------------------

Re: Sorting results by Range

Posted by Erick Erickson <er...@gmail.com>.
OK, I think I get it now. There's nothing in Solr that I know of that'll let you
do this. Although you could add a clause boosted insanely high, something
like date_modified:[aug10 TO aug 20]^10000 that would bubble your target
results toward the top of your list... Note, that's not the correct
date syntax...

You'd probably have to have your app do the fine-grained sorting, that
is of the,
say, 20 docs returned in your list, sort them by your aug10-20 dates.

Best
Erick

On Mon, Aug 22, 2011 at 10:07 AM, Sowmya V.B. <vb...@gmail.com> wrote:
> Hi Eric
>
> Let me clarify:
>
> 1) The user gives a query, and also has an option to choose the "from" and
> "to" values for a specific field.
> (For Eg: Give me all documents that match the query Solr Users, but with
> those that were last updated between 10th and 20th of August ranked on top)
>
> -Over here, I am currently using a BoostQuery functionality, to do this.
> However, along with this, I want to provide an additional option of Sorting
> these "boosted" results based on that range chosen above.
>
> 2) I don't want to use an Fq option because, it will filter out the
> documents not within this range. I want the all the results relevant to the
> query, with an option to put a sorted list of documents, that satisfy the
> range requirements.
>
> I hope I made my query clearer now.
>
> S.
>
> On Mon, Aug 22, 2011 at 4:01 PM, Erick Erickson <er...@gmail.com>wrote:
>
>> I guess I'm having trouble understanding this. "I just wanted all the
>> results,
>> along with an option to sort the results, if the user wants it."
>>
>> What does "all the results" mean? The results you would have had if it
>> you didn't have a sort? There's no way to guarantee that the results
>> returned
>> by relevance contain the range you want, unless you really
>> do return all the results, possibly thousands to millions of documents.
>>
>>
>> If you used an fq clause, the app could sort the results without executing
>> another search if you wanted to sort them by date...
>>
>> Best
>> Erick
>>
>>
>> On Mon, Aug 22, 2011 at 3:56 AM, Sowmya V.B. <vb...@gmail.com> wrote:
>> > Dear All
>> >
>> > I have been searching on how to sort Solr results based on a range
>> > query..but did not find decipherable answers. Hence, mailing again. Sorry
>> if
>> > the query was already posed -i was not able to find it.
>> >
>> > I want to add an option to sort the results, based on a field range
>> chosen.
>> > (For eg: "Sort Results based on the Field A, being from 20 to 30", "Sort
>> in
>> > such a way that the date field points to dates between August 1st to
>> 10th"
>> > etc)
>> >
>> > I don't want to Filter the results. I just wanted all the results, along
>> > with an option to sort the results, if the user wants it.
>> >
>> > Is there anything in Solr, the allows me sort by range?
>> >
>> > I Tried giving something like this, following the Sort-without-range
>> > specification syntax, and needless to say, it threw me syntax error.
>> >
>> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sort=Field1:[20TO
>> > 30] asc
>> >
>> >
>> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sortBy=Field1:[20TO
>> > 30] asc
>> > -Does not throw a Syntax error,  but does not seem to work anyways.
>> >
>> > Thanks for the help!
>> >
>> > Sowmya.
>> >
>> > --
>> > Sowmya V.B.
>> > ----------------------------------------------------
>> > Losing optimism is blasphemy!
>> > http://vbsowmya.wordpress.com
>> > ----------------------------------------------------
>> >
>>
>
>
>
> --
> Sowmya V.B.
> ----------------------------------------------------
> Losing optimism is blasphemy!
> http://vbsowmya.wordpress.com
> ----------------------------------------------------
>

Re: Sorting results by Range

Posted by "Sowmya V.B." <vb...@gmail.com>.
Hi Eric

Let me clarify:

1) The user gives a query, and also has an option to choose the "from" and
"to" values for a specific field.
(For Eg: Give me all documents that match the query Solr Users, but with
those that were last updated between 10th and 20th of August ranked on top)

-Over here, I am currently using a BoostQuery functionality, to do this.
However, along with this, I want to provide an additional option of Sorting
these "boosted" results based on that range chosen above.

2) I don't want to use an Fq option because, it will filter out the
documents not within this range. I want the all the results relevant to the
query, with an option to put a sorted list of documents, that satisfy the
range requirements.

I hope I made my query clearer now.

S.

On Mon, Aug 22, 2011 at 4:01 PM, Erick Erickson <er...@gmail.com>wrote:

> I guess I'm having trouble understanding this. "I just wanted all the
> results,
> along with an option to sort the results, if the user wants it."
>
> What does "all the results" mean? The results you would have had if it
> you didn't have a sort? There's no way to guarantee that the results
> returned
> by relevance contain the range you want, unless you really
> do return all the results, possibly thousands to millions of documents.
>
>
> If you used an fq clause, the app could sort the results without executing
> another search if you wanted to sort them by date...
>
> Best
> Erick
>
>
> On Mon, Aug 22, 2011 at 3:56 AM, Sowmya V.B. <vb...@gmail.com> wrote:
> > Dear All
> >
> > I have been searching on how to sort Solr results based on a range
> > query..but did not find decipherable answers. Hence, mailing again. Sorry
> if
> > the query was already posed -i was not able to find it.
> >
> > I want to add an option to sort the results, based on a field range
> chosen.
> > (For eg: "Sort Results based on the Field A, being from 20 to 30", "Sort
> in
> > such a way that the date field points to dates between August 1st to
> 10th"
> > etc)
> >
> > I don't want to Filter the results. I just wanted all the results, along
> > with an option to sort the results, if the user wants it.
> >
> > Is there anything in Solr, the allows me sort by range?
> >
> > I Tried giving something like this, following the Sort-without-range
> > specification syntax, and needless to say, it threw me syntax error.
> >
> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sort=Field1:[20TO
> > 30] asc
> >
> >
> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sortBy=Field1:[20TO
> > 30] asc
> > -Does not throw a Syntax error,  but does not seem to work anyways.
> >
> > Thanks for the help!
> >
> > Sowmya.
> >
> > --
> > Sowmya V.B.
> > ----------------------------------------------------
> > Losing optimism is blasphemy!
> > http://vbsowmya.wordpress.com
> > ----------------------------------------------------
> >
>



-- 
Sowmya V.B.
----------------------------------------------------
Losing optimism is blasphemy!
http://vbsowmya.wordpress.com
----------------------------------------------------

Re: Sorting results by Range

Posted by Erick Erickson <er...@gmail.com>.
I guess I'm having trouble understanding this. "I just wanted all the results,
along with an option to sort the results, if the user wants it."

What does "all the results" mean? The results you would have had if it
you didn't have a sort? There's no way to guarantee that the results returned
by relevance contain the range you want, unless you really
do return all the results, possibly thousands to millions of documents.


If you used an fq clause, the app could sort the results without executing
another search if you wanted to sort them by date...

Best
Erick


On Mon, Aug 22, 2011 at 3:56 AM, Sowmya V.B. <vb...@gmail.com> wrote:
> Dear All
>
> I have been searching on how to sort Solr results based on a range
> query..but did not find decipherable answers. Hence, mailing again. Sorry if
> the query was already posed -i was not able to find it.
>
> I want to add an option to sort the results, based on a field range chosen.
> (For eg: "Sort Results based on the Field A, being from 20 to 30", "Sort in
> such a way that the date field points to dates between August 1st to 10th"
> etc)
>
> I don't want to Filter the results. I just wanted all the results, along
> with an option to sort the results, if the user wants it.
>
> Is there anything in Solr, the allows me sort by range?
>
> I Tried giving something like this, following the Sort-without-range
> specification syntax, and needless to say, it threw me syntax error.
> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sort=Field1:[20TO
> 30] asc
>
> http://localhost:8080/ir4llsolr/select?indent=on&version=2.2&q=xyz&start=0&rows=10&fl=title%2Cdate&sortBy=Field1:[20TO
> 30] asc
> -Does not throw a Syntax error,  but does not seem to work anyways.
>
> Thanks for the help!
>
> Sowmya.
>
> --
> Sowmya V.B.
> ----------------------------------------------------
> Losing optimism is blasphemy!
> http://vbsowmya.wordpress.com
> ----------------------------------------------------
>