Indexing Date for search in date range

Topics: Customizing Orchard, Writing modules
Aug 27, 2012 at 2:08 PM

 

I Made index for date field i make some thing like the following:

1- when indexing:

context.DocumentIndex.Add("creationdate",Convert.ToInt32(DateTools.DateToString(part.CreationDate.Value,DateTools.Resolution.DAY))).Store();

var datefrom = Convert.ToDateTime(Request.QueryString[fields + "From"].Trim());                       

var dateto = Convert.ToDateTime(Request.QueryString["To"].Trim()); 

                      searchBuilder.WithinRange(field,Convert.ToInt32(DateTools.DateToString(datefrom, DateTools.Resolution.DAY)), Convert.ToInt32(DateTools.DateToString(dateto, DateTools.Resolution.DAY)));

 

when i search i get all contents or nothing if i add numeric range query

or using add AsFilter() to Within method .

what's the problem

Coordinator
Aug 28, 2012 at 4:40 AM

I don't understand why you need to write code for this. Doesn't indexing already work out of the box?

Sep 2, 2012 at 11:06 AM

it worked now by make indexing like common part

and add range query filter to lucene withRange function with min date and max date

thanks for your time