Re: Solr query for date

2009-01-08 Thread prerna07



My requirement is to fetch records whthin range of 45 days.

1) ?q=date_field:[NOW TO NOW-45DAYS] is not returning any results
2)  ?q=date_field:[NOW TO NOW+45DAYS] is throwing exception

however I get correct results when i run following  query : 
 ?q=date_field:[* TO NOW]

Please suggest the correct query for range with days.

Thanks,
Prerna





Akshay-8 wrote:
 
 You can use DateMath as:
 
 date_field:[NOW TO NOW+45DAYS]
 
 On Wed, Jan 7, 2009 at 3:00 PM, prerna07 pkhandelw...@sapient.com wrote:
 

 Hi,

  what will be the syntax of this sql query
  SELECT * FROM table WHERE date  SYSDATE and  date SYSDATE+45
  in solr format ?

  I need to fetch records where date is between current date and 45 days
 from
 today.

 Thanks,
 Prerna
 --
 View this message in context:
 http://www.nabble.com/Solr-query-for-date-tp21327696p21327696.html
 Sent from the Solr - User mailing list archive at Nabble.com.


 
 
 -- 
 Regards,
 Akshay Ukey.
 
 Enjoy your job, make lots of money, work within the law. Choose any two.
 -Author Unknown.
 
 

-- 
View this message in context: 
http://www.nabble.com/Solr-query-for-date-tp21327696p21349038.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: Solr query for date

2009-01-08 Thread Akshay
On Thu, Jan 8, 2009 at 3:38 PM, prerna07 pkhandelw...@sapient.com wrote:




 My requirement is to fetch records whthin range of 45 days.

 1) ?q=date_field:[NOW TO NOW-45DAYS] is not returning any results

this works for me if you interchange the range limits viz. [NOW-45DAYS TO
NOW]


 2)  ?q=date_field:[NOW TO NOW+45DAYS] is throwing exception

this too works for me.

Have you defined the date_field field as solr.DateField type in the schema?
date_field should be of type solr.DateField to use range query.



 however I get correct results when i run following  query :
  ?q=date_field:[* TO NOW]

 Please suggest the correct query for range with days.

 Thanks,
 Prerna





 Akshay-8 wrote:
 
  You can use DateMath as:
 
  date_field:[NOW TO NOW+45DAYS]
 
  On Wed, Jan 7, 2009 at 3:00 PM, prerna07 pkhandelw...@sapient.com
 wrote:
 
 
  Hi,
 
   what will be the syntax of this sql query
   SELECT * FROM table WHERE date  SYSDATE and  date SYSDATE+45
   in solr format ?
 
   I need to fetch records where date is between current date and 45 days
  from
  today.
 
  Thanks,
  Prerna
  --
  View this message in context:
  http://www.nabble.com/Solr-query-for-date-tp21327696p21327696.html
  Sent from the Solr - User mailing list archive at Nabble.com.
 
 
 
 
  --
  Regards,
  Akshay Ukey.
 
  Enjoy your job, make lots of money, work within the law. Choose any two.
  -Author Unknown.
 
 

 --
 View this message in context:
 http://www.nabble.com/Solr-query-for-date-tp21327696p21349038.html
 Sent from the Solr - User mailing list archive at Nabble.com.




-- 
Regards,
Akshay Ukey.


Re: Solr query for date

2009-01-08 Thread prerna07


1) [NOW-45 TO NOW] works for me now.
2) [NOW TO NOW+45DAYS] is still throwing following exception : 

--
message org.apache.lucene.queryParser.ParseException: Cannot parse
'dateToTest_product_s:[NOW TO NOW 45DAYS]': Encountered 45DAYS at line 1,
column 33. Was expecting: ] ... 

description The request sent by the client was syntactically incorrect
(org.apache.lucene.queryParser.ParseException: Cannot parse
'dateToTest_product_s:[NOW TO NOW 45DAYS]': Encountered 45DAYS at line 1,
column 33. Was expecting: ] ... ).
-
I am running the query on slr admin on internet explorer.

i have defined date field as date in schema.xml


Akshay-8 wrote:
 
 On Thu, Jan 8, 2009 at 3:38 PM, prerna07 pkhandelw...@sapient.com wrote:
 



 My requirement is to fetch records whthin range of 45 days.

 1) ?q=date_field:[NOW TO NOW-45DAYS] is not returning any results
 
 this works for me if you interchange the range limits viz. [NOW-45DAYS TO
 NOW]
 

 2)  ?q=date_field:[NOW TO NOW+45DAYS] is throwing exception
 
 this too works for me.
 
 Have you defined the date_field field as solr.DateField type in the
 schema?
 date_field should be of type solr.DateField to use range query.
 


 however I get correct results when i run following  query :
  ?q=date_field:[* TO NOW]

 Please suggest the correct query for range with days.

 Thanks,
 Prerna





 Akshay-8 wrote:
 
  You can use DateMath as:
 
  date_field:[NOW TO NOW+45DAYS]
 
  On Wed, Jan 7, 2009 at 3:00 PM, prerna07 pkhandelw...@sapient.com
 wrote:
 
 
  Hi,
 
   what will be the syntax of this sql query
   SELECT * FROM table WHERE date  SYSDATE and  date SYSDATE+45
   in solr format ?
 
   I need to fetch records where date is between current date and 45
 days
  from
  today.
 
  Thanks,
  Prerna
  --
  View this message in context:
  http://www.nabble.com/Solr-query-for-date-tp21327696p21327696.html
  Sent from the Solr - User mailing list archive at Nabble.com.
 
 
 
 
  --
  Regards,
  Akshay Ukey.
 
  Enjoy your job, make lots of money, work within the law. Choose any
 two.
  -Author Unknown.
 
 

 --
 View this message in context:
 http://www.nabble.com/Solr-query-for-date-tp21327696p21349038.html
 Sent from the Solr - User mailing list archive at Nabble.com.


 
 
 -- 
 Regards,
 Akshay Ukey.
 
 

-- 
View this message in context: 
http://www.nabble.com/Solr-query-for-date-tp21327696p21349994.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: Solr query for date

2009-01-08 Thread Akshay
On Thu, Jan 8, 2009 at 4:46 PM, prerna07 pkhandelw...@sapient.com wrote:



 1) [NOW-45 TO NOW] works for me now.
 2) [NOW TO NOW+45DAYS] is still throwing following exception :

 --
 message org.apache.lucene.queryParser.ParseException: Cannot parse
 'dateToTest_product_s:[NOW TO NOW 45DAYS]': Encountered 45DAYS at line 1,

notice in the error message that + sign in your query string is getting
converted to space. you need to escape the + sign and properly url encode
the query before querying solr. See here:
http://wiki.apache.org/solr/SolrQuerySyntax#urlescaping


 column 33. Was expecting: ] ...

 description The request sent by the client was syntactically incorrect
 (org.apache.lucene.queryParser.ParseException: Cannot parse
 'dateToTest_product_s:[NOW TO NOW 45DAYS]': Encountered 45DAYS at line 1,
 column 33. Was expecting: ] ... ).
 -
 I am running the query on slr admin on internet explorer.

 i have defined date field as date in schema.xml


 Akshay-8 wrote:
 
  On Thu, Jan 8, 2009 at 3:38 PM, prerna07 pkhandelw...@sapient.com
 wrote:
 
 
 
 
  My requirement is to fetch records whthin range of 45 days.
 
  1) ?q=date_field:[NOW TO NOW-45DAYS] is not returning any results
 
  this works for me if you interchange the range limits viz. [NOW-45DAYS TO
  NOW]
 
 
  2)  ?q=date_field:[NOW TO NOW+45DAYS] is throwing exception
 
  this too works for me.
 
  Have you defined the date_field field as solr.DateField type in the
  schema?
  date_field should be of type solr.DateField to use range query.
 
 
 
  however I get correct results when i run following  query :
   ?q=date_field:[* TO NOW]
 
  Please suggest the correct query for range with days.
 
  Thanks,
  Prerna
 
 
 
 
 
  Akshay-8 wrote:
  
   You can use DateMath as:
  
   date_field:[NOW TO NOW+45DAYS]
  
   On Wed, Jan 7, 2009 at 3:00 PM, prerna07 pkhandelw...@sapient.com
  wrote:
  
  
   Hi,
  
what will be the syntax of this sql query
SELECT * FROM table WHERE date  SYSDATE and  date SYSDATE+45
in solr format ?
  
I need to fetch records where date is between current date and 45
  days
   from
   today.
  
   Thanks,
   Prerna
   --
   View this message in context:
   http://www.nabble.com/Solr-query-for-date-tp21327696p21327696.html
   Sent from the Solr - User mailing list archive at Nabble.com.
  
  
  
  
   --
   Regards,
   Akshay Ukey.
  
   Enjoy your job, make lots of money, work within the law. Choose any
  two.
   -Author Unknown.
  
  
 
  --
  View this message in context:
  http://www.nabble.com/Solr-query-for-date-tp21327696p21349038.html
  Sent from the Solr - User mailing list archive at Nabble.com.
 
 
 
 
  --
  Regards,
  Akshay Ukey.
 
 

 --
 View this message in context:
 http://www.nabble.com/Solr-query-for-date-tp21327696p21349994.html
 Sent from the Solr - User mailing list archive at Nabble.com.




-- 
Regards,
Akshay Ukey.


Re: Solr query for date

2009-01-07 Thread prerna07


Is this necessary to define date_field as  fieldType name=date
class=solr.DateField  in schema.xml. OR Solr query can work on text field
type ?


Akshay-8 wrote:
 
 You can use DateMath as:
 
 date_field:[NOW TO NOW+45DAYS]
 
 On Wed, Jan 7, 2009 at 3:00 PM, prerna07 pkhandelw...@sapient.com wrote:
 

 Hi,

  what will be the syntax of this sql query
  SELECT * FROM table WHERE date  SYSDATE and  date SYSDATE+45
  in solr format ?

  I need to fetch records where date is between current date and 45 days
 from
 today.

 Thanks,
 Prerna
 --
 View this message in context:
 http://www.nabble.com/Solr-query-for-date-tp21327696p21327696.html
 Sent from the Solr - User mailing list archive at Nabble.com.


 
 
 -- 
 Regards,
 Akshay Ukey.
 
 Enjoy your job, make lots of money, work within the law. Choose any two.
 -Author Unknown.
 
 

-- 
View this message in context: 
http://www.nabble.com/Solr-query-for-date-tp21327696p21328961.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: Solr query for date

2009-01-07 Thread Akshay
You can use DateMath as:

date_field:[NOW TO NOW+45DAYS]

On Wed, Jan 7, 2009 at 3:00 PM, prerna07 pkhandelw...@sapient.com wrote:


 Hi,

  what will be the syntax of this sql query
  SELECT * FROM table WHERE date  SYSDATE and  date SYSDATE+45
  in solr format ?

  I need to fetch records where date is between current date and 45 days
 from
 today.

 Thanks,
 Prerna
 --
 View this message in context:
 http://www.nabble.com/Solr-query-for-date-tp21327696p21327696.html
 Sent from the Solr - User mailing list archive at Nabble.com.




-- 
Regards,
Akshay Ukey.

Enjoy your job, make lots of money, work within the law. Choose any two.
-Author Unknown.