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 Kamal Palei <pa...@gmail.com> on 2013/05/29 08:40:58 UTC

Sorting results by last update date

Hi All
I am trying to sort the results as per last updated date. My url looks as
below.

*&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
588]&fq=salary:[0 TO 500] OR
salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
+sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
+sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
json.nl=map&sort=last_updated_date asc
*
With this I get the data in ascending order of last updated date.

If I am trying to sort data in descending order, I use below url

*&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
588]&fq=salary:[0 TO 500] OR
salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
+sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
+sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
json.nl=map&sort=last_updated_date desc*

Here the data set is not ordered properly, mostly it looks to me data is
ordered on basis of score, not last updated date.

Can somebody tell me what I am missing here, why *desc* is not working
properly for me.

Thanks
kamal

Re: Sorting results by last update date

Posted by Kamal Palei <pa...@gmail.com>.
Jack
Thank you so much for detailed answer.

-BR,
Kamal


On Thu, May 30, 2013 at 6:18 PM, Jack Krupansky <ja...@basetechnology.com>wrote:

> I wrote "Otherwise, it would miss dates after the start of today", but
> that should be "Otherwise, it would miss documents with times after the
> start of today if the current time is before noon."
>
> But use "*" and you will be better off anyway.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Jack Krupansky
> Sent: Thursday, May 30, 2013 8:27 AM
>
> To: solr-user@lucene.apache.org
> Subject: Re: Sorting results by last update date
>
> You can just use "NOW/DAY" for a filter that would only change once a day:
>
> [NOW/DAY-60DAY TO NOW/DAY]
>
> Oops... make that:
>
> [NOW/DAY-60DAY TO NOW/DAY+1DAY]
>
> Otherwise, it would miss dates after the start of today.
>
> Even better, make it:
>
> [NOW/DAY-60DAY TO *]
>
> -- Jack Krupansky
>
> -----Original Message----- From: Kamal Palei
> Sent: Thursday, May 30, 2013 5:41 AM
> To: solr-user@lucene.apache.org
> Subject: Re: Sorting results by last update date
>
> Thanks Shalini...
> It is solr 3.6.2
> Instead of NOW, I can use today's date.... (I did not know this cache
> issue,, thanks).
>
> Later I realized , it looks it is my mistake that misleads asc and desc
> ordering result.
> After I get data from solr, again I do mysql query where the order changes
> again.
>
> Regards
> Kamal
>
>
> On Wed, May 29, 2013 at 2:54 PM, Shalin Shekhar Mangar <
> shalinmangar@gmail.com> wrote:
>
>  On Wed, May 29, 2013 at 12:10 PM, Kamal Palei <pa...@gmail.com>
>> wrote:
>>
>> > Hi All
>> > I am trying to sort the results as per last updated date. My url looks
>> > as
>> > below.
>> >
>> > *&fq=last_updated_date:[NOW-**60DAY TO NOW]&fq=experience:[0 TO
>> > 588]&fq=salary:[0 TO 500] OR
>> >
>> >
>> salary:0&fq=-bundle:job&fq=-**bundle:panel&fq=-bundle:page&**
>> fq=-bundle:article&spellcheck=**true&q=+java
>> >
>> >
>> +sip&fl=id,entity_id,entity_**type,bundle,bundle_name,label,**
>> is_comment_count,ds_created,**ds_changed,score,path,url,is_**
>> uid,tos_name,zm_parent_entity,**ss_filemime,ss_file_entity_**
>> title,ss_file_entity_url,ss_**field_uid&spellcheck.q=+java
>> >
>> >
>> +sip&qf=content^40&qf=label^5.**0&qf=tos_content_extra^0.1&qf=**
>> tos_name^3.0&hl.fl=content&mm=**1&q.op=AND&wt=json&
>> > json.nl=map&sort=last_updated_**date asc
>> > *
>> > With this I get the data in ascending order of last updated date.
>> >
>> > If I am trying to sort data in descending order, I use below url
>> >
>> > *&fq=last_updated_date:[NOW-**60DAY TO NOW]&fq=experience:[0 TO
>> > 588]&fq=salary:[0 TO 500] OR
>> >
>> >
>> salary:0&fq=-bundle:job&fq=-**bundle:panel&fq=-bundle:page&**
>> fq=-bundle:article&spellcheck=**true&q=+java
>> >
>> >
>> +sip&fl=id,entity_id,entity_**type,bundle,bundle_name,label,**
>> is_comment_count,ds_created,**ds_changed,score,path,url,is_**
>> uid,tos_name,zm_parent_entity,**ss_filemime,ss_file_entity_**
>> title,ss_file_entity_url,ss_**field_uid&spellcheck.q=+java
>> >
>> >
>> +sip&qf=content^40&qf=label^5.**0&qf=tos_content_extra^0.1&qf=**
>> tos_name^3.0&hl.fl=content&mm=**1&q.op=AND&wt=json&
>> > json.nl=map&sort=last_updated_**date desc*
>> >
>> > Here the data set is not ordered properly, mostly it looks to me data is
>> > ordered on basis of score, not last updated date.
>> >
>> > Can somebody tell me what I am missing here, why *desc* is not working
>> > properly for me.
>> >
>> >
>> What is the field type of last_update_date? Which version of Solr?
>>
>> A side note: Using NOW in a filter query is ineffecient because it doesn't
>> use your filter cache effectively. Round it to nearest time interval
>> instead. See http://java.dzone.com/**articles/solr-date-math-now-**
>> and-filter <http://java.dzone.com/articles/solr-date-math-now-and-filter>
>>
>> --
>> Regards,
>> Shalin Shekhar Mangar.
>>
>>

Re: Sorting results by last update date

Posted by Jack Krupansky <ja...@basetechnology.com>.
I wrote "Otherwise, it would miss dates after the start of today", but that 
should be "Otherwise, it would miss documents with times after the start of 
today if the current time is before noon."

But use "*" and you will be better off anyway.

-- Jack Krupansky

-----Original Message----- 
From: Jack Krupansky
Sent: Thursday, May 30, 2013 8:27 AM
To: solr-user@lucene.apache.org
Subject: Re: Sorting results by last update date

You can just use "NOW/DAY" for a filter that would only change once a day:

[NOW/DAY-60DAY TO NOW/DAY]

Oops... make that:

[NOW/DAY-60DAY TO NOW/DAY+1DAY]

Otherwise, it would miss dates after the start of today.

Even better, make it:

[NOW/DAY-60DAY TO *]

-- Jack Krupansky

-----Original Message----- 
From: Kamal Palei
Sent: Thursday, May 30, 2013 5:41 AM
To: solr-user@lucene.apache.org
Subject: Re: Sorting results by last update date

Thanks Shalini...
It is solr 3.6.2
Instead of NOW, I can use today's date.... (I did not know this cache
issue,, thanks).

Later I realized , it looks it is my mistake that misleads asc and desc
ordering result.
After I get data from solr, again I do mysql query where the order changes
again.

Regards
Kamal


On Wed, May 29, 2013 at 2:54 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, May 29, 2013 at 12:10 PM, Kamal Palei <pa...@gmail.com>
> wrote:
>
> > Hi All
> > I am trying to sort the results as per last updated date. My url looks 
> > as
> > below.
> >
> > *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> > 588]&fq=salary:[0 TO 500] OR
> >
> >
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
> >
> >
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
> >
> >
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> > json.nl=map&sort=last_updated_date asc
> > *
> > With this I get the data in ascending order of last updated date.
> >
> > If I am trying to sort data in descending order, I use below url
> >
> > *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> > 588]&fq=salary:[0 TO 500] OR
> >
> >
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
> >
> >
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
> >
> >
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> > json.nl=map&sort=last_updated_date desc*
> >
> > Here the data set is not ordered properly, mostly it looks to me data is
> > ordered on basis of score, not last updated date.
> >
> > Can somebody tell me what I am missing here, why *desc* is not working
> > properly for me.
> >
> >
> What is the field type of last_update_date? Which version of Solr?
>
> A side note: Using NOW in a filter query is ineffecient because it doesn't
> use your filter cache effectively. Round it to nearest time interval
> instead. See http://java.dzone.com/articles/solr-date-math-now-and-filter
>
> --
> Regards,
> Shalin Shekhar Mangar.
> 

Re: Sorting results by last update date

Posted by Jack Krupansky <ja...@basetechnology.com>.
You can just use "NOW/DAY" for a filter that would only change once a day:

[NOW/DAY-60DAY TO NOW/DAY]

Oops... make that:

[NOW/DAY-60DAY TO NOW/DAY+1DAY]

Otherwise, it would miss dates after the start of today.

Even better, make it:

[NOW/DAY-60DAY TO *]

-- Jack Krupansky

-----Original Message----- 
From: Kamal Palei
Sent: Thursday, May 30, 2013 5:41 AM
To: solr-user@lucene.apache.org
Subject: Re: Sorting results by last update date

Thanks Shalini...
It is solr 3.6.2
Instead of NOW, I can use today's date.... (I did not know this cache
issue,, thanks).

Later I realized , it looks it is my mistake that misleads asc and desc
ordering result.
After I get data from solr, again I do mysql query where the order changes
again.

Regards
Kamal


On Wed, May 29, 2013 at 2:54 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, May 29, 2013 at 12:10 PM, Kamal Palei <pa...@gmail.com>
> wrote:
>
> > Hi All
> > I am trying to sort the results as per last updated date. My url looks 
> > as
> > below.
> >
> > *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> > 588]&fq=salary:[0 TO 500] OR
> >
> >
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
> >
> >
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
> >
> >
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> > json.nl=map&sort=last_updated_date asc
> > *
> > With this I get the data in ascending order of last updated date.
> >
> > If I am trying to sort data in descending order, I use below url
> >
> > *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> > 588]&fq=salary:[0 TO 500] OR
> >
> >
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
> >
> >
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
> >
> >
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> > json.nl=map&sort=last_updated_date desc*
> >
> > Here the data set is not ordered properly, mostly it looks to me data is
> > ordered on basis of score, not last updated date.
> >
> > Can somebody tell me what I am missing here, why *desc* is not working
> > properly for me.
> >
> >
> What is the field type of last_update_date? Which version of Solr?
>
> A side note: Using NOW in a filter query is ineffecient because it doesn't
> use your filter cache effectively. Round it to nearest time interval
> instead. See http://java.dzone.com/articles/solr-date-math-now-and-filter
>
> --
> Regards,
> Shalin Shekhar Mangar.
> 


Re: Sorting results by last update date

Posted by Kamal Palei <pa...@gmail.com>.
Thanks Shalini...
It is solr 3.6.2
Instead of NOW, I can use today's date.... (I did not know this cache
issue,, thanks).

Later I realized , it looks it is my mistake that misleads asc and desc
ordering result.
 After I get data from solr, again I do mysql query where the order changes
again.

Regards
Kamal


On Wed, May 29, 2013 at 2:54 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, May 29, 2013 at 12:10 PM, Kamal Palei <pa...@gmail.com>
> wrote:
>
> > Hi All
> > I am trying to sort the results as per last updated date. My url looks as
> > below.
> >
> > *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> > 588]&fq=salary:[0 TO 500] OR
> >
> >
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
> >
> >
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
> >
> >
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> > json.nl=map&sort=last_updated_date asc
> > *
> > With this I get the data in ascending order of last updated date.
> >
> > If I am trying to sort data in descending order, I use below url
> >
> > *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> > 588]&fq=salary:[0 TO 500] OR
> >
> >
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
> >
> >
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
> >
> >
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> > json.nl=map&sort=last_updated_date desc*
> >
> > Here the data set is not ordered properly, mostly it looks to me data is
> > ordered on basis of score, not last updated date.
> >
> > Can somebody tell me what I am missing here, why *desc* is not working
> > properly for me.
> >
> >
> What is the field type of last_update_date? Which version of Solr?
>
> A side note: Using NOW in a filter query is ineffecient because it doesn't
> use your filter cache effectively. Round it to nearest time interval
> instead. See http://java.dzone.com/articles/solr-date-math-now-and-filter
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: Sorting results by last update date

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, May 29, 2013 at 12:10 PM, Kamal Palei <pa...@gmail.com> wrote:

> Hi All
> I am trying to sort the results as per last updated date. My url looks as
> below.
>
> *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> 588]&fq=salary:[0 TO 500] OR
>
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
>
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
>
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> json.nl=map&sort=last_updated_date asc
> *
> With this I get the data in ascending order of last updated date.
>
> If I am trying to sort data in descending order, I use below url
>
> *&fq=last_updated_date:[NOW-60DAY TO NOW]&fq=experience:[0 TO
> 588]&fq=salary:[0 TO 500] OR
>
> salary:0&fq=-bundle:job&fq=-bundle:panel&fq=-bundle:page&fq=-bundle:article&spellcheck=true&q=+java
>
> +sip&fl=id,entity_id,entity_type,bundle,bundle_name,label,is_comment_count,ds_created,ds_changed,score,path,url,is_uid,tos_name,zm_parent_entity,ss_filemime,ss_file_entity_title,ss_file_entity_url,ss_field_uid&spellcheck.q=+java
>
> +sip&qf=content^40&qf=label^5.0&qf=tos_content_extra^0.1&qf=tos_name^3.0&hl.fl=content&mm=1&q.op=AND&wt=json&
> json.nl=map&sort=last_updated_date desc*
>
> Here the data set is not ordered properly, mostly it looks to me data is
> ordered on basis of score, not last updated date.
>
> Can somebody tell me what I am missing here, why *desc* is not working
> properly for me.
>
>
What is the field type of last_update_date? Which version of Solr?

A side note: Using NOW in a filter query is ineffecient because it doesn't
use your filter cache effectively. Round it to nearest time interval
instead. See http://java.dzone.com/articles/solr-date-math-now-and-filter

-- 
Regards,
Shalin Shekhar Mangar.

Re: Sorting results by last update date

Posted by Tom Gullo <sp...@gmail.com>.
&sort=last_updated_date desc

Maybe adding %20 will help:

&sort=last_updated_date%20desc



--
View this message in context: http://lucene.472066.n3.nabble.com/Sorting-results-by-last-update-date-tp4066692p4066986.html
Sent from the Solr - User mailing list archive at Nabble.com.