bq: The requirement doesn't really let me use the query like that. Why not? Why can't you index a start date and end date? At ingestion time if your data is a start date and number of days the event (let's call it an event) will run, why not index a second field that contains the end date along with the number of days the event runs?
Or perhaps use the DateRangeField rather than separate start/end dates to make your queries easier? (see: https://cwiki.apache.org/confluence/display/solr/Working+with+Dates) Many times I'll add extra fields to the doc at index time to support the search use-cases. Almost always, the extra work at index time is repaid many times over in query efficiency. Best, Erick On Wed, Nov 23, 2016 at 2:27 PM, Sadheera Vithanage <sadhee...@gmail.com> wrote: > Thankyou Erick, > > The requirement doesn't really let me use the query like that. > > Rather, what I would be storing in my document is the day number. > > E.g: Day : 1, Day : 2 etc I can even store this in milliseconds > like 86400000,172800000. > > And I want to compare if those days falls within the difference of current > day and another day. > > Something like below. > > StoredDay_ms:ms(NOW/DAY+1DAY,NOW/DAY) > > And it should return the documents with values set to 86400000 as > StoredDay_ms. > > Thank you very much, Really appreciate your help. > > On Wed, Nov 23, 2016 at 6:20 PM, Erick Erickson <erickerick...@gmail.com> > wrote: > >> I wouldn't do it this way, it's far more complex than you need. Try >> fq=Startdate__D:[NOW/DAY-7DAYS TO NOW/DAY+1DAY]. >> >> Why the weird NOW/DAY+1DAY? Well, that makes fq clauses far >> more likely to be reused, see: >> https://lucidworks.com/blog/2012/02/23/date-math-now-and-filter-queries/ >> >> Best, >> Erick >> >> On Tue, Nov 22, 2016 at 7:29 PM, Sadheera Vithanage <sadhee...@gmail.com> >> wrote: >> > Hi All, >> > >> > I am struggling to get the difference of 2 days and return the matching >> > documents. >> > >> > I got the below function query to work, however I am unable to pass a >> > fieldname for *u *in frange function. >> > >> > {!frange l=0 u=864000000}ms(NOW,StartDate__d) >> > >> > >> > What I really want to do is compare the start date with today's date and >> > return the documents that falls within a date range.For example 7 days. >> > >> > Thank you. >> > >> > -- >> > Regards >> > >> > Sadheera Vithanage >> > > > > -- > Regards > > Sadheera Vithanage